RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.TextToFloat Function

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

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

SysUtils

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 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) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!