function AsOctal(i : integer) : string;
var
Digit : byte;
begin
while (i > 0) do
begin
Digit := (i AND 7); // This is a bitwize AND, meaning:
// 001001010011010 (Some number)
// AND 000000000000111 ( 7 )
// ---------------
// 000000000000010 ( 2 )
{ convert this digit to Octal }
i := (i shr 3); // this "shifts" the number right 3 bits:
// 001001010011010 (Some number)
// becomes 000001001010011 (Some number DIV 8)
end;
end;
OR
procedure TForm1.Button1Click(Sender: TObject);
var
c : char;
i : integer;
begin
c := 'b'; {or any character}
i := ord(c);
edit1.text := IntToStr((i shr 6) and 7) + IntToStr((i shr 3) and 7) +
IntToStr(i and 7);
end;
Result is '142' octal (=98 decimal).
I have not tried but it should work.
"Guillermo Sanchez" <guillerm...@codetel.com.do> wrote in message
news:3d1a1cab_1@dnews...
This appears to work.
procedure TForm1.Button1Click(Sender: TObject);
var
Decimal: integer;
Remainder: integer;
Fit: integer;
begin
Decimal := 10;
Fit := Decimal;
repeat
Remainder := Fit mod 8; {change 8 to 2 for binary,etc.}
Fit := Fit div 8;
Memo1.Lines.Add(IntToStr(Remainder));
until Fit = 0;
end;