Autor Beitrag
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Sa 01.03.03 20:36 
Ich habe ein mathematisches Programm, welches mit Teilern arbeitet. Ich habe eine gewisse Anzahl an Zählern und an Nennern. Nun teile ich diese und schreibe die Ergebnisse in ein Memo. Und nun meine Frage:

Wie kann ich überprüfen ob eine Zahl natürlich (1, 2, 3, 4, 5, etc.) ist und wie kann ich sie dann heraus filtern?

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Sa 01.03.03 20:42 
Hallo Doc!

Ich hoffe, ich verstehe dich recht:
ausblenden Quelltext
1:
2:
3:
4:
function IsNatuerlich(const E: Extended): Boolean;
begin
  Result := (E = Trunc(E)) and (E > 0);
end;
Gruß wulfskin!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.


Zuletzt bearbeitet von wulfskin am Sa 01.03.03 21:14, insgesamt 1-mal bearbeitet
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Sa 01.03.03 21:11 
ACHTUNG: 0 gehört nicht zur Menge der natürlichen Zahlen.
Ich würd's so machen:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
function IsN(E:Extended;WithZero:boolean=False):boolean;
begin
 Result:=(E=round(E));
 if WithZero then Result:=Result and (E>=0) else
 Result:=Result and (E>0);
end;

Dann kann man gleich noch angeben, ob Gruppe N oder Gruppe N0.

maxk

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
derDoc Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: So 02.03.03 09:28 
Danke, ich werde das mal anwenden.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.