The FloatToStrF function converts a floating point number Value into a displayable string, with great control over the formatting via the Format, Precision, and Digits values.

The Value type may be any of the floating point types.

The Format parameter is defined by theTFloatFormat (SysUtils) type :

ffCurrency

eg : ?2,345.60

ffExponent

eg : 2.3456E+04

ffFixed

eg : 2345.60

ffGeneral

eg : 2345.6

ffNumber

eg : 2,345.6

The other parameters are dependent on this format. See TFloatFormat for full details.

Version 2 of this function is for use within threads. You furnish the FormatSettings record before invoking the call. It takes a local copy of global formatting variables that make the routine thread safe.

Notes

You can change the currency string from the default (such as '$' in the USA, '?' in the UK) using theCurrencyString variable.

You can change the position of the currency string using the CurrencyFormat variable.

You can change the decimal point value by setting theDecimalSeparator character.

You can change the thousands separator value by setting the ThousandSeparator character.

If the full number of digits before the decimal point (the mantissa) cannot be displayed, then the display reverts to the exponent (scientific) format.

Example code : Display numbers as financial values

// Full Unit code.// -----------------------------------------------------------// You must store this code in a unit called Unit1 with a form// called Form1 that has an OnCreate event called FormCreate.

// Full Unit code.// -----------------------------------------------------------// You must store this code in a unit called Unit1 with a form// called Form1 that has an OnCreate event called FormCreate.

// Full Unit code.// -----------------------------------------------------------// You must store this code in a unit called Unit1 with a form// called Form1 that has an OnCreate event called FormCreate.

// Full Unit code.// -----------------------------------------------------------// You must store this code in a unit called Unit1 with a form// called Form1 that has an OnCreate event called FormCreate.