Autor Beitrag
Ironhead
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP,Kanotix 5

BeitragVerfasst: So 07.01.07 02:18 
Ich flipp gleich quer.

Ich weiß jetzt grad nich wonach ich bei dem Problem suchen soll.
Also, ich habe 15 Edit und 15 Labels beim eintrag ins Edit wird ins nebenstehende Label die Zahlen eingetragen.
meine Gleitkommawerte werden bis zur Zahl 9999,99 korrekt übernommen, wird im 10 Feld nun die Zahl 1 eingetrage, steht im Label auch 1,00 so wie es sein soll, aber beim Label was mir die Gasamtsumme anzeigt springt er auf 10001,00, also schmeißt er mir 1 Cent mit dazu, was ja nach Adam Riese und Eva Zwerg eigendlich nicht stimmt(glaub ich).



ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
var
Fixzahl1,Fixzahl2,Fixzahl3,Fixzahl4,
Fixzahl5,Fixzahl6,Fixzahl7,Fixzahl8,Fixzahl9,Fixzahl10,Fixzahl11,Fixzahl12,Fixzahl13,Fixzahl14,
Fixzahl15,Fixergebnis: Real;
begin
Fixzahl1 := StrToFloat(FixLabel16.Caption);
Fixzahl2 := StrToFloat(FixLabel17.Caption);
Fixzahl3 := StrToFloat(FixLabel18.Caption);
Fixzahl4 := StrToFloat(FixLabel19.Caption);
Fixzahl5 := StrToFloat(FixLabel20.Caption);
Fixzahl6 := StrToFloat(FixLabel21.Caption);
Fixzahl7 := StrToFloat(FixLabel22.Caption);
Fixzahl8 := StrToFloat(FixLabel23.Caption);
Fixzahl9 := StrToFloat(FixLabel24.Caption);
Fixzahl10 := StrToFloat(FixLabel25.Caption);
Fixzahl11 := StrToFloat(FixLabel26.Caption);
Fixzahl12 := StrToFloat(FixLabel27.Caption);
Fixzahl13 := StrToFloat(FixLabel28.Caption);
Fixzahl14 := StrToFloat(FixLabel29.Caption);
Fixzahl15 := StrToFloat(FixLabel30.Caption);

Fixergebnis := Fixzahl1+Fixzahl2+Fixzahl3+Fixzahl4+Fixzahl5+Fixzahl6+Fixzahl7+
Fixzahl8+Fixzahl9+Fixzahl10+Fixzahl11+Fixzahl12+Fixzahl13+Fixzahl14+Fixzahl15;

Label56.Caption := (FloatToStrF(Fixergebnis, ffFixed, 6, 2));
end;


Ich hoffe mir kann einer mein Denkfehler erklähren, denn mitleiweile geh ich am stock.
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 07.01.07 02:54 
Was macht denn die Function "FloatToStrF"?

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 07.01.07 03:05 
Wie der Name sagt: Eine Float-Zahl mit einem bestimmten Format in einen String umwandeln...

Jedenfalls würde ich mal die Genauigkeit erhöhen... Statt der 6 ein wenig mehr...
Denn 9999,99 + 1 = 10000,99! Das geht aber mit nur 6 signifikanten Stellen nicht darzustellen, zähl mal von der ersten 1 her ab! Die Genauigkeit, in deinem Fall die 6 gibt an, wieviele Stellen von der ersten an ungleich Null sein dürfen!
Beispiele für 6, 2 als Parameter:
100001,00
1000010,00
Mit den Einsen sind 6 Stellen signifikant. Davor und danach kommen nur Nullen.
Ironhead Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP,Kanotix 5

BeitragVerfasst: So 07.01.07 03:50 
Jetz hab ichs geschnallt (Denk ich) ich hab jetz die Zahl auf 8 erhöht um eine zahl im Hunderttausender bereich zu bekommen, und die 2 für die 2 Stellen hinterm Komma.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 07.01.07 03:54 
Richtig! Mit 8 und 2 als Parameter bekommst du bei 2 Nachkommastellen, die beide nicht Null sind, bis zu 6 Ziffern vor dem Komma.
Ironhead Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 57

Win XP,Kanotix 5

BeitragVerfasst: So 07.01.07 03:56 
Wieder was gelernt, Dank dir rechtherzlich