Substr.StrToFloat Method

function StrToFloat(const S: Substring): Double; overload; inline;

Converts S to a Double by ToDouble's rules, correctly rounded.

#NameTypeDescription
1SSubstring

Returns: Double

Remarks:

A refused text raises EConvertError: '<text>' is not a valid floating point value.

Examples

A text with an exponent.

uses Substr, System.SysUtils;

procedure Example;
begin
    Assert(StrToFloat(Substring('125e-2')) = 1.25);
end;