Substring.ToSingle Method

Overload List

#SignatureDescription
1function ToSingle: Single; overload; inline;Converts the text to a Single, correctly rounded.
2class function ToSingle(const S: Substr.Substring): Single; overload; static; inline;
3class function ToSingle(const S: string): Single; overload; static; inline;

Overload 1: function ToSingle: Single; overload; inline;

Converts the text to a Single, correctly rounded.

Returns: Single - The value; NAN, INF, +INF and -INF are read as special values.

Remarks:

Accepted: leading spaces, a sign, digits with at most one decimal separator (FormatSettings.DecimalSeparator), an exponent (E or e, a sign, at least one digit), trailing spaces; the sign and the exponent are optional. Any other text, or one whose nearest Single is infinite, raises EConvertError: '<text>' is not a valid floating point value for Single type. The class forms take every text kind.

Examples

A text with an exponent.

uses Substr;

procedure Example;
begin
    Assert(Substring('25e-1').ToSingle = 2.5);
end;

Overload 2: class function ToSingle(const S: Substr.Substring): Single; overload; static; inline;

#NameTypeDescription
1SSubstr.Substring

Returns: Single

Overload 3: class function ToSingle(const S: string): Single; overload; static; inline;

#NameTypeDescription
1Sstring

Returns: Single