Description |
The FloatToStr function converts a floating point number Value into a displayable string.
The value is displayed to 15 digits of precision.
The Value type may be any of the floating point types.
Values before the decimal point (the mantissa) exceeding the display capacity (15) result in a display using the exponent value, such as 1.2E9.
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 decimal point value by setting the DecimalSeparator character.
Use the FloatToStrF function for control over the formatting.
|
|
Related commands |
DecimalSeparator |
|
The character used to display the decimal point |
FloatToStrF |
|
Convert a floating point value to a string with formatting |
|
|
|
Example code : Display various sizes of extended data 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. unit Unit1; interface uses SysUtils, // Unit containing the FloatToStr command Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
amount1, amount2, amount3 : Extended;
begin amount1 := 1234567890.123456789; // High precision number amount2 := 1234567890123456.123; // High mantissa digits amount3 := 1E100; // High value number
ShowMessage('Amount1 = '+FloatToStr(amount1));
ShowMessage('Amount2 = '+FloatToStr(amount2));
ShowMessage('Amount3 = '+FloatToStr(amount3));
end; end.
|
Hide full unit code |
Amount1 = 1234567890.12346
Amount2 = 1.23456789012346E15
Amount3 = 1E100
|
|