function IntToStr(Value: UInt64; const TS: String): String; overload;
begin
Str(Value, Result);
if (TS = '') then
Exit;
if (Value > 999) then
Insert(TS, Result, Length(Result)-2);
if (Value > 999999) then
Insert(TS, Result, Length(Result)-6);
if (Value > 999999999) then
Insert(TS, Result, Length(Result)-10);
if (Value > 999999999999) then
Insert(TS, Result, Length(Result)-14);
if (Value > 999999999999999) then
Insert(TS, Result, Length(Result)-18);
if (Value > 999999999999999999) then
Insert(TS, Result, Length(Result)-22);
end;
function IntToStr(Value: Int64; const TS: String): String; overload;
begin
Str(Value, Result);
if (TS = '') then
Exit;
if (Value > 999) or (Value < -999) then
Insert(TS, Result, Length(Result)-2);
if (Value > 999999) or (Value < -999999)then
Insert(TS, Result, Length(Result)-6);
if (Value > 999999999) or (Value < -999999999) then
Insert(TS, Result, Length(Result)-10);
if (Value > 999999999999) or (Value < -999999999999) then
Insert(TS, Result, Length(Result)-14);
if (Value > 999999999999999) or (Value < -999999999999999) then
Insert(TS, Result, Length(Result)-18);
if (Value > 999999999999999999) or (Value < -999999999999999999) then
Insert(TS, Result, Length(Result)-22);
end;
var
S, Sep: String;
U: UInt64;
I: Int64;
begin
Sep := DefaultFormatSettings.ThousandSeparator;
U := High(UInt64);
S := IntToStr(U,Sep);
writeln(U,' -> ',S);
I := High(Int64);
S := IntToStr(I,Sep);
writeln(I,' -> ',S);
I := Low(Int64);
S := IntToStr(I,Sep);
writeln(I,' -> ',S);
end.