Autor Beitrag
Fabian
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42



BeitragVerfasst: Do 25.07.02 14:03 
Hallo,
Wie kann ich überprüfen ob es sich bei einer Zahl um eine natürliche Zahl handelt ?
wwerner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 185



BeitragVerfasst: Do 25.07.02 14:36 
Wie liegt den die Zahl vor? (integer ligint, real, extendet, string)

_________________
Gruß

Wolfgang

----------
zu hause ist es doch am schönsten
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Do 25.07.02 14:36 
Hallo,

ersmal musst du wissen was du unter einer Natürlichen Zahl verstehst. In meinem Beispiel gehe ich davon aus, das du nach DIN 5473 ganze Positive Zahle einschließlich der 0 meinst.

ausblenden Quelltext
1:
2:
3:
4:
function IsNatl(Wert: Extended): BOOLEAN;
begin
  Result := (Wert>-1) AND (frac(Wert) = 0);
end;  // IsNatl


Diese Funktion liefert TRUE wenn der übergebene Wert nach den oben beschriebenen Faktoren eine Natürliche Zahl ist.

Gruß
Klabautermann