Autor Beitrag
Green
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: So 21.05.06 21:31 
wie kann ich eine Extended zu Integer konvertieren und dabei auf eine bestimmte anzahl an nachkommastellen runden?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 21.05.06 21:35 
Ein Integer kann gar keine Nachkommastellen speichern.

_________________
Markus Kinzler.
Green Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

Windows XP Home
Delphi 6 Enterprise
BeitragVerfasst: So 21.05.06 21:39 
hmm... und wie kann ich ein Float (Extended) zu Str konvertieren?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 21.05.06 21:43 
FloatToStr()

_________________
Markus Kinzler.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: So 21.05.06 22:18 
user profile iconGreen hat folgendes geschrieben:
wie kann ich eine Extended zu Integer konvertieren und dabei auf eine bestimmte anzahl an nachkommastellen runden?


Du könntest höchstens round() benutzen. DAs rundet halt die Kommastellen ganz weg.

Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
DelphiAnfänger
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 112

Win XP, Firefox 2.0, IE6
Delphi 5 Prof., Delphi 2005 PE
BeitragVerfasst: So 21.05.06 22:24 
user profile iconGreen hat folgendes geschrieben:
wie kann ich eine Extended zu Integer konvertieren und dabei auf eine bestimmte anzahl an nachkommastellen runden?

Du kannst auf nachkommastellen runden aber das ist dann kein integer:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure blablub;
Var x:extended
begin
 x:=1.2345678;
 x:=(Round(x*100))/100; //rundet auf zwei Nachkommastellen
 Edit1.text:=floattostr(x); //in Edit1 müsste jetzt "1,23" stehen
end;

bei der markierten klammer bin ich mir nicht sicher ob du sie auch weglassen kannst musst du ausprobieren
Mossi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 99
Erhaltene Danke: 2

Win XP, Linux
D7 Enterprise, K3 Prof
BeitragVerfasst: Mo 22.05.06 16:57 
Es gäbe auch noch roundTo(Zahl, decimal)
Also zum Beispiel
ausblenden Delphi-Quelltext
1:
x := roundTo(1.2345, -2); // => x = 1.23