Autor Beitrag
elduchte
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 199

Win 2000, Win XP
Delphi 7
BeitragVerfasst: Sa 24.05.03 13:03 
Hallo,
ich habe folgendes Problem:
Ich gebe mittels einer TEdit-Komponente eine Zahl ein. Diese Zahl wandel ich in eine Fließkommazahl um. Danach will ich von der Zahl 4-Prozent berechnen. Das Ergebnis wird dann nach Umwandlung auch wieder in einer TEdit-Komponente dargestellt. Allerdings ist das Ergebnis ungenau: 4% von 1 = 0,04 ---> Die Komponente zeigt 0,0399999 an.

Was mache ich falsch bzw. wie kann ich das Ergebnis auf 2 Stellen nach dem Komma runden ???

Danke
Andreas
delphisual
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 89

WIN 2000
D5 Prof
BeitragVerfasst: Sa 24.05.03 13:29 
ausblenden Delphi-Quelltext
1:
Form1.Edit1.Text:=FloattoStrf(round(deineRealVariable * 100)/100);					

_________________
(Wer ein Problem definiert, hat es schon halb gelöst.)
delphisual
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 89

WIN 2000
D5 Prof
BeitragVerfasst: Sa 24.05.03 13:32 
Sry was vergessen:
ausblenden Delphi-Quelltext
1:
2:
Form1.Edit1.Text:=
FloattoStrf(round(deineRealVariable * 100)/100,ffFixed,5,2);

:P

_________________
(Wer ein Problem definiert, hat es schon halb gelöst.)