Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi FloatToStr in nonVCL? (https://www.delphipraxis.net/70832-floattostr-nonvcl.html)

ErazerZ 5. Jun 2006 15:29


FloatToStr in nonVCL?
 
hey,
ich komme hier einfach nicht weiter, wie ich eine fließkommer zahl in einen string umwandle, mit Str() bekomm ich nur einen blödsinn heraus, und mit wvsprintf() finde ich auch keinen weg ..

ErazerZ 5. Jun 2006 15:50

Re: FloatToStr in nonVCL?
 
ich glaub ich habs, auf 2 stellen gerundet ..
Delphi-Quellcode:
function FloatToStr(E: Extended): String;
var
  S: String;
begin
  Str(E:2:2, S);
  FloatToStr := S;
end;

sniper_w 5. Jun 2006 15:51

Re: FloatToStr in nonVCL?
 
Ich habe jetzt nicht delphi hier aber mit str muss es gehen, einfach man OH nachschlagen.

EDIT:
Delphi-Quellcode:
function FloatToStr(E: Extended): String;
begin
  Str(E:2:2, Result);
end;

marabu 5. Jun 2006 15:56

Re: FloatToStr in nonVCL?
 
Delphi-Quellcode:
function FloatToStr(e: Extended; width, decimals: Byte): String;
var
  i: integer;
begin
  Str(e:width:decimals, Result);
  if DecimalSeparator = ',' then
    repeat
      i := Pos('.', Result);
      if i > 0 then
        Result[i] := DecimalSeparator;
    until i = 0;
end;
Grüße vom marabu

ErazerZ 5. Jun 2006 16:05

Re: FloatToStr in nonVCL?
 
danke sniper_w und marabu


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:16 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz