SysUtils.TryStrToFloat

From RAD Studio VCL Reference
Jump to: navigation, search

Contents

Delphi Information

From SysUtils.pas

	function TryStrToFloat(const S: string; out Value: Extended): Boolean; overload;
 
	function TryStrToFloat(const S: string;
		out Value: Extended;
		const FormatSettings: TFormatSettings): Boolean; overload;
 
	function TryStrToFloat(const S: string; out Value: Double): Boolean; overload;
 
	function TryStrToFloat(const S: string;
		out Value: Double;
		const FormatSettings: TFormatSettings): Boolean; overload;
 
	function TryStrToFloat(const S: string; out Value: Single): Boolean; overload;
 
	function TryStrToFloat(const S: string;
		out Value: Single;
		const FormatSettings: TFormatSettings): Boolean; overload;


Unit: SysUtils

Type: function

Visibility: public

C++ Information

From SysUtils.hpp

	bool __fastcall TryStrToFloat(System::UnicodeString S, long double & Value);


Unit: SysUtils

Type: function

Description

Converts a given string to a floating-point value with a boolean success code.


Use TryStrToFloat to convert a astring, 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 defines the character that must be used as a decimal point. Thousand separators and currency symbols are not allowed in the string. If S does not contain a valid value, TryStrToFloat returns Default.

TryStrToFloat places the result in Value, and returns True if the conversion was successful, False otherwise.

The first three forms of TryStrToFloat are not thread-safe, because they use localization information contained in global variables. The second three forms of TryStrToFloat, which are thread-safe, refer to localization information contained in the FormatSettings parameter. Before calling the thread-safe forms of TryStrToFloat, you must populate FormatSettings with localization information. To populate FormatSettings with a set of default locale values, call GetLocaleFormatSettings.

See Also

Personal tools
Translations
Newest Version