Mit ist/war es so, als wenn es mit Val ging ... kann aber auch nur eine Sinnestäuschung/Gedächtnisstörung sein
Delphi-Quellcode:
var
i: UInt64;
e: Integer;
begin
Val('10376293541461622783', i, e);
if i = 1037629354146162278 then
ShowMessage('falsch');
if i = $8FFFFFFFFFFFFFFF then
ShowMessage('richtig');
Val('$8FFFFFFFFFFFFFFF', i, e);
if i = $8FFFFFFFFFFFFFFF then
ShowMessage('richtig');
end;
'n alter Code von mir
Delphi-Quellcode:
Function fromStr(Const S: AnsiString; Out i: LargeWord; Default: LargeWord = 0): ByteBool;
Var P: Integer;
Begin
P := 1;
While (P <= _Length(S)) and (S[P] <= ' ') do Inc(P);
Result := (P <= _Length(S)) and (S[P] in ['0'..'9']);
While (P <= _Length(S)) and (S[P] in ['0'..'9', scThousandSeparator]) do Inc(P);
While (P <= _Length(S)) and (S[P] <= ' ') do Inc(P);
Result := Result and (P > _Length(S));
If Result Then Begin
i := 0;
P := 1;
While P <= _Length(S) do Begin
If S[P] in ['0'..'9'] Then Begin
If (i > 1844674407370955161) or ((i = 1844674407370955161) and ((Byte(S[P]) xor $30) > 5)) Then Begin
i := Default;
Result := False;
Exit;
End;
i := i * 10 + (Byte(S[P]) xor $30);
End;
Inc(P);
End;
End Else i := Default;
End;
[edit]
gekürzt sieht es wohl in etwa so aus:
Delphi-Quellcode:
Function StrToUInt64(Const S: String; Out i: UInt64; Default: UInt64 = 0): Boolean;
Var P: Integer;
Begin
P := 1;
Result := (P <= Length(S)) and (S[P] >= '0') and (S[P] <= '9');
While (P <= Length(S)) and (S[P] >= '0') and (S[P] <= '9') do Inc(P);
Result := Result and (P > Length(S));
If Result Then Begin
i := 0;
P := 1;
While P <= Length(S) do Begin
If (i > 1844674407370955161) or ((i = 1844674407370955161) and (Ord(S[P]) - Ord('0') > 5)) Then Begin
i := Default;
Result := False;
Exit;
End;
i := i * 10 + Ord(S[P]) - Ord('0');
Inc(P);
End;
End Else i := Default;
End;
Ein Therapeut entspricht 1024 Gigapeut.