RAD Studio VCL Reference
SysUtils.StrToFloatDef Function

Converts a given string to a floating-point value with error default.

function StrToFloatDef(const S: string; const Default: Extended): Extended; overload;
function StrToFloatDef(const S: string; const Default: Extended; const FormatSettings: TFormatSettings): Extended; overload;
Extended StrToFloatDef(const AnsiString S, const Extended Default);
Extended StrToFloatDef(const AnsiString S, const Extended Default, const TFormatSettings FormatSettings);

Use StrToFloatDef to convert a string, S, to a floating-point value. S 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 DecimalSeparator global variable or its TFormatSettings equivalent defines the character that must be used as a decimal point. Thousand separators and currency symbols are not allowed in the string. If S doesn't contain a valid value, StrToFloatDef returns Default.  

The first form of StrToFloatDef is not thread-safe, because it uses localization information contained in global variables. The second form of StrToFloatDef, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of StrToFloatDef, 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!