Converts a floating point value to a string.
function FloatToStr(Value: Extended): string; overload; function FloatToStr(Value: Extended; const FormatSettings: TFormatSettings): string; overload;
AnsiString FloatToStr(Extended Value); AnsiString FloatToStr(Extended Value, const TFormatSettings FormatSettings);
SysUtils
FloatToStr converts the floating-point value given by Value to its string representation. The conversion uses general number format with 15 significant digits.
For greater control over the formatting of the string, use the FloatToStrF function.
The first form of FloatToStr is not thread-safe, because it uses localization information contained in global variables. The second form of FloatToStr, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of FloatToStr, you must populate FormatSettings with localization information. To populate FormatSettings with a set of default locale values, call GetLocaleFormatSettings.
Delphi Examples:
{ This example displays the compiler version number in the text field. } procedure TForm1.FormCreate(Sender: TObject); begin Edit1.Text := FloatToStr(System.CompilerVersion); end;
{ This example shows how to use the ArcTan and FloatToStr functions. } procedure TForm1.Button1Click(Sender: TObject); var ex : Extended; mystring : String; begin ex := 16 * ArcTan(1/5) - 4 * ArcTan(1/239); // Machin's formula mystring := FloatToStr(ex); Edit2.Text := mystring; end; procedure TForm1.FormCreate(Sender: TObject); var ex : Extended; myString : String; begin ex := Pi; mystring := FloatToStr(ex); Edit1.Text := mystring; end;
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|