Autor Beitrag
pupu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 104

WinXP
Borland Delphi 7, Turbo Pascal 7
BeitragVerfasst: Fr 11.08.06 17:23 
Gibt es eine Anweisung in Delphi, mit der ich auf eine bestimmte Zahl an Nachkommastellen runden kann? Oder muss ich da auf jeden fall ne Prozedur schreiben, die das erreicht, stattdessen ich eine fertige Delhi-Prozedur nehmen kann?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Fr 11.08.06 17:36 
Hallo

roundto aus unit math. Gibts aber glaube erst ab Delphi6.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 11.08.06 17:39 
Wenn nicht kannst du die das einfach selber basteln:

ausblenden Delphi-Quelltext
1:
Wert := Trunc(Wert * 100)/100;					

_________________
Markus Kinzler.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Fr 11.08.06 17:47 
user profile iconmkinzler hat folgendes geschrieben:
Wenn nicht kannst du die das einfach selber basteln:

ausblenden Delphi-Quelltext
1:
Wert := Trunc(Wert * 100)/100;					

Floating-Point-Macken nicht vergessen (und gleichzeitig Aufrunden):
ausblenden Delphi-Quelltext
1:
Wert := Trunc(0.5 + Wert * 100)/100;					

Dieser Schnipsel rundet auf 2 Dezimalstellen (10^2).

_________________
Na denn, dann. Bis dann, denn.
pupu Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 104

WinXP
Borland Delphi 7, Turbo Pascal 7
BeitragVerfasst: Di 15.08.06 12:15 
ohne es jetzt probiert zu haben: verfälsch ich den wert nich indem ich 0,5 hinzuaddier?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Di 15.08.06 12:19 
user profile iconpupu hat folgendes geschrieben:
ohne es jetzt probiert zu haben: verfälsch ich den wert nich indem ich 0,5 hinzuaddier?
Wenn du es kaufm. gerundet haben willst nicht den

0.4 + 0.5 ergibt 0.9 ohne Nachkommastellen = 0
0.5 + 0.5 ergibt 1.0 ohne Nachkommastellen = 1

Banken runden allerdings immer ab.

_________________
Markus Kinzler.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Di 15.08.06 12:20 
user profile iconpupu hat folgendes geschrieben:
ohne es jetzt probiert zu haben: verfälsch ich den wert nich indem ich 0,5 hinzuaddier?

Nee:
1,2375 * 100 = 123,75 + 0,5 = 124,25, davon Ganzahl = 124, das durch 100 = 1,24.

_________________
Na denn, dann. Bis dann, denn.