From RAD Studio API Documentation
Jump to: navigation, search


function StrToFloat(const S: string): Extended;
function StrToFloat(const S: string; const AFormatSettings: TFormatSettings): Extended;


extern DELPHI_PACKAGE System::Extended __fastcall StrToFloat(const System::UnicodeString S)/* overload */;


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


Converts a given string to a floating-point value.

Use StrToFloat to convert a string, S, to a floating-point value (leading and trailing blanks are ignored).

  • 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 an optional number.

The DecimalSeparator global variable or its TFormatSettings equivalent defines the character that is used as a decimal point. Thousand separators and currency symbols are not allowed in the string. If S does not contain a valid value, StrToFloat raises an EConvertError exception.

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

See Also

Code Examples