![]() |
Probleme Mit dem Runden von Zahlen
Delphi-Quellcode:
den Code Hab ich aus dem Netz
function Runden(zahl: double; stellen: integer): double;
var multi: double; begin multi:=IntPower(10, stellen); zahl:=round(zahl*multi); result:=zahl/multi; end;
Delphi-Quellcode:
Kann mir das Bitte Jemand helfen Knobel Schon 3 stunden Dran
Resistor := floattostr(((strtofloat(edit_UV.text)-
strtofloat(edit_UD.text))/strtofloat(edit_ID.text))*1000); if StrTofloat(Resistor)>999 then begin //kohm pnl_calculated_resistor.caption := FloatToStr(Runden(((strtofloat(resistor)/ 1000)), 2)+' KOhm'); ******Erzeugt Incompitable types 'string' 'Double' end; if StrTofloat(Resistor)<1000 then begin //ohm pnl_calculated_resistor.caption := FloatToStr(Runden(((strtofloat(resistor)/ 1)), 2)+' KOhm'); ******Erzeugt Incompitable types 'string' 'Double' end; |
Re: Probleme Mit dem Runden von Zahlen
Delphi-Quellcode:
Deine Klammern waren nicht korrekt, hoffe ich habe sie richtig korrigiert.
if StrTofloat(Resistor)>999 then begin //kohm
pnl_calculated_resistor.caption := FloatToStr( Runden( ( strtofloat(resistor) / 1000) , 2)) +' KOhm'; end; if StrTofloat(Resistor)<1000 then begin //ohm pnl_calculated_resistor.caption := FloatToStr( Runden( ( strtofloat(resistor)/ 1), 2))+' kOhm'; end; Grüße Klaus |
Re: Probleme Mit dem Runden von Zahlen
Danke jetzt klappts :bounce2:
Immer diese Kleinigkeiten |
Re: Probleme Mit dem Runden von Zahlen
Zitat:
Schon mal versucht, die Zahlen 1.5 und 2.5 zu runden? Tja, einmal wird aufgerundet und einmal abgerundet. (=Bankers Rounding) ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:43 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