CynicRus
2013-01-22 02:37:03
Hi. This is other funny function:
Backward conversion:
Output:
program new;
function IntToASCII(Value: Integer; Digits: Integer): string;
var
I: Integer;
begin
Result := '';
I := 0;
while I < Digits do
begin
Result := Result + Chr(Value and $FF);
Value := Value shr 8;
Inc(I);
end;
end;
begin
WriteLn(InttoASCII(12,1));
end.
Backward conversion:
function ASCIIToInt(S: string; Digits: Integer): Integer;
var
I: Integer;
begin
Result := 0;
I := Min(Length(S), Digits);
while I > 0 do
begin
Result := Result shl 8;
Result := Ord(S[I]) + Result;
Dec(I);
end;
end;
Output: