RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.TextToFloat Function

Converts a null-terminated string to a floating-point value.

Pascal
function TextToFloat(Buffer: PAnsiChar; var Value; ValueType: TFloatValue): Boolean; overload;
function TextToFloat(Buffer: PAnsiChar; var Value; ValueType: TFloatValue; const FormatSettings: TFormatSettings): Boolean; overload;
function TextToFloat(Buffer: PWideChar; var Value; ValueType: TFloatValue): Boolean; overload;
function TextToFloat(Buffer: PWideChar; var Value; ValueType: TFloatValue; const FormatSettings: TFormatSettings): Boolean; overload;
C++
Boolean TextToFloat(PAnsiChar Buffer,  Value, TFloatValue ValueType);
Boolean TextToFloat(PAnsiChar Buffer,  Value, TFloatValue ValueType, const TFormatSettings FormatSettings);
Boolean TextToFloat(PWideChar Buffer,  Value, TFloatValue ValueType);
Boolean TextToFloat(PWideChar Buffer,  Value, TFloatValue ValueType, const TFormatSettings FormatSettings);

Use TextToFloat to convert a null-terminated string, Buffer, to a floating-point value. The string must consist of an optional sign (+ or -), a string of digits with an optional decimal point, and an optional mantissa. The mantissa consists of 'E' or 'e' followed by an optional sign (+ or -) and a whole number. Leading and trailing blanks are ignored. 

The converted value is assigned to the Value parameter, which must be of type Extended or System::Currency, as indicated by the ValueType parameter. 

TextToFloat returns true if the conversion is successful, or false if the Buffer does not contain a valid floating-point value. 

The first form of TextToFloat is not thread-safe, because it uses localization information contained in global variables. The second form of TextToFloat, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of TextToFloat, you must populate FormatSettings with localization information. To populate FormatSettings with a set of default locale values, call GetLocaleFormatSettings

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!