From RAD Studio API Documentation
Jump to: navigation, search


function TextToFloat(Buffer: PAnsiChar; var Value; ValueType: TFloatValue): Boolean;
function TextToFloat(Buffer: PAnsiChar; var Value; ValueType: TFloatValue; const AFormatSettings: TFormatSettings): Boolean;


extern DELPHI_PACKAGE bool __fastcall TextToFloat(char * Buffer, void *Value, System::Sysutils::TFloatValue ValueType)/* overload */;


Type Visibility Source Unit Parent
function public
System.AnsiStrings System.AnsiStrings


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

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 AFormatSettings parameter. Before calling the thread-safe form of TextToFloat, you must populate AFormatSettings with localization information. To populate AFormatSettings with a set of default locale values, call TFormatSettings.Create.

Code Examples