How to remove an exhibitor from a formatted float in Delphi

Given a double value, for example 1.00500000274996E-8, how to convert it into a non-scientific format with the maximum number of digits after the decimal point - in this case, with 8 digits, will this be 1.00500000?

The conversion should not contain zeros, so 2007 will be released as 2007, and 2012.33 and 2012.33.

I tried a lot of combinations using Format, FormatFloat, FloatToStrF, but didn't seem to be able to hit the jackpot. Thanks so much for any help.

Edit: I have to clarify that I'm trying to convert it to a string representation without the Exponent (E) part.

+5
source share
2 answers

FormatFloat('0.######################', 1.00500000274996E-8) gotta do the trick.

Output: 0.0000000100500000274996

, .

+7

. John Herbster " " CodeCentral. , , , ... CC-:

This module includes
(a) functions for converting a floating binary point number to its *exact* decimal representation in an AnsiString;
(b) functions for parsing the floating point types into sign, exponent, and mantissa; and
(c) function for analyzing a extended float number into its type (zero, normal, infinity, etc.)

Its intended use is for trouble shooting problems with floating point numbers.

DecimalRounding .

+2

All Articles