Hello,
after one delphi session every one of my single floats has been saving into a wordpad as this weird 2.73500000000000E+0003
2.00000000000000E+0002 notation, same goes with printing is there any way to reverse this ?

Recommended Answers

All 3 Replies

not sure wither this applies to Delphi or not , but in pascal we usually use this command to print the float in normal notation
write(y:x:z);
where y represents the float
x represents the number of digits for integer part of the float
z represents the number of digits for fractional part of the float
example
write(y:6:2);
the output will look like this : 65.22
I don't know how to write the float to a text file with the normal notation

Hello,

In Delphi, you can almost transform any data type to string through some built-in functions. For float variables, there is FloatToStr, FloatToStrF. In your case, I think the second one fits better.

function FloatToStrF(Value: Extended; Format : TFloatFormat; Precision, Digits : Integer) : String; - for more info, check Delphi's help

Example

procedure SomeProc;
var sTemp : String;
     aValueToPrint : Float;
begin
     aValueToPrint := 23.32543123;
     sTemp := StrToFloatF(aValueToPrint, , ffGeneral, 15, 2); //the output is 23.33
end;

Cheers,
Ionut

Hello,
after one delphi session every one of my single floats has been saving into a wordpad as this weird 2.73500000000000E+0003
2.00000000000000E+0002 notation, same goes with printing is there any way to reverse this ?

here you can find all of the information that you need
http://rvelthuis.de/articles/articles-floats.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.