![]() |
Probleme mit Prozentrechnung
Delphi-Quellcode:
var
wert : string; wiederstand : string; tolerance: string; prozent: extended;
Delphi-Quellcode:
*****z.B.
wiederstand := floattostr((strtofloat(wert)*10000));
Delphi-Quellcode:
tolerance := floattostr( (strtofloat(wiederstand)/100)*prozent);
Delphi-Quellcode:
Und hier die rechnung für Toleranz minimum
prozent:=(1);
Delphi-Quellcode:
(floattostr(((strtofloat(wiederstand)-tolerance)/
1))+' Ohm'); und maximum
Delphi-Quellcode:
(floattostr(((strtofloat(wiederstand)+tolerance)/
1))+' Ohm'); mit den Formeln hab ich so meine probleme |
Re: Probleme mit Prozentrechnung
Delphi-Quellcode:
Minimum:
tolerance := floattostr( (strtofloat(wiederstand)*prozent/100);
Delphi-Quellcode:
Maximum:
floattostr(strtofloat(wiederstand)-tolerance)+' Ohm');
Delphi-Quellcode:
Kannst Du mal genauer beschreiben wo Dein Problem ist?
floattostr(strtofloat(wiederstand)+tolerance)+' Ohm';
Grüße Klaus |
Re: Probleme mit Prozentrechnung
Speicher dir doch vor dem Berechnen die Werte aus den Edits in einem rechenbaren Format zwischen. Dann wird das ganze um einiges übersichtlicher.
Delphi-Quellcode:
Und Widerstand schreibt man trotzdem ohne ie.
var
wert : Extended; wiederstand : Extended; tolerance: Extended; prozent: extended; sTolMin, sTolMax: string; ... prozent:=1; widerstand := wert*10000; tolerance := widerstand/100*prozent; sTolMin := FloatToStr((widerstand-tolerance)/1)+' Ohm'); sTolMax:= FloatToStr((widerstand-tolerance)/1)+' Ohm'); |
Re: Probleme mit Prozentrechnung
wo ist dein problem?...die prozentformel sollte passen.
Das einzige, was ich zu bemämgeln habe (hatte ich imho schon in dem anderen thread gesagt), ist das ständige umwandeln von string in die zahlentypen (integer/extended) vice versa. Warum nicht *nur* in extended rechnen und nur zur Ausgabe in string umwandeln? gut und das /1 kannst du dir schenken, da zahl/1=zahl Gruß Frank |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz