Hallo,
ich habe mal versucht in den Quellen von FPC nach StrToFloat zu forschen und bin hier fündig geworden:
\fpcsrc\rtl\objpas\sysutils\sysstr.inc"
Dort liest man folgendes:
Code: Alles auswählen
Function StrToFloat(Const S : String; Const FormatSettings: TFormatSettings) : Extended;
Begin // texttofloat handles NIL properly
If Not TextToFloat(Pchar(pointer(S)),Result,FormatSettings) then
Raise EConvertError.createfmt(SInValidFLoat,[S]);
End;
Also StrToFloat ruft TextToFloat auf. Soweit verstanden...
Und das hier ist TextToFloat
Code: Alles auswählen
Function TextToFloat(Buffer: PChar; Out Value: Extended; Const FormatSettings: TFormatSettings): Boolean;
Var
E,P : Integer;
S : String;
Begin
S:=StrPas(Buffer);
//ThousandSeparator not allowed as by Delphi specs
if (FormatSettings.ThousandSeparator <> FormatSettings.DecimalSeparator) and
(Pos(FormatSettings.ThousandSeparator, S) <> 0) then
begin
Result := False;
Exit;
end;
if (FormatSettings.DecimalSeparator <> '.') and
(Pos('.', S) <>0) then
begin
Result := False;
Exit;
end;
P:=Pos(FormatSettings.DecimalSeparator,S);
If (P<>0) Then
S[P] := '.';
try
Val(trim(S),Value,E);
{ on x87, a floating point exception may be pending in case of an invalid
input value -> trigger it now }
{$if defined(cpui386) or (defined(cpux86_64) and not(defined(win64))) or defined(cpui8086)}
asm
fwait
end;
{$endif}
except
E:=1;
end;
Result:=(E=0);
End;