just curious why the following code fails to convert uint64 value in string representation ?
var
num: UInt64;
s: string;
err: Integer;
begin
s := '18446744073709551615'; // High(UInt64)
Val(s, num, err);
if err <> 0 then
raise Exception.Create('Failed to convert UInt64 at ' + IntToStr(err)); // returns 20
end.
Delphi XE2
Am I missing something here ?
According to the documentation,
I agree the documentation is a bit vague; indeed, what exactly does form mean, and exactly what is meant by a signed real number (especially if
numis an integer type)?Still, I think the part to highlight is signed. In this case, you want an integer, and so
Smust be a sequence of characters that form a signed integer. But then your maximum isHigh(Int64) = 9223372036854775807