[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
IntToBin
Author : DJ_Sannie
E-Mail : DJ_Sannie@yahoo.com
Date : March 30, 2004
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
IntToBin
Author : DJ_Sannie
E-Mail : DJ_Sannie@yahoo.com
Date : March 30, 2004
function IntToBin( Int: Integer ): String;
var
i, j: Integer;
begin
Result := '';
i := 0;
j := 1;
while i = 0 do
if( ( Int Mod (j*2) ) = Int )
then i := j
else j := j * 2;
while i > 0 do
begin
if( ( Int div i ) > 0 ) then
begin
Int := Int - i;
Result := Result + '1';
end
else Result := Result + '0';
i := Trunc( i * 0.5 );
end;
end;
function Int64ToBin(Num: Int64; Length: integer): string;
var
i: Int64;
begin
i := 1;
Result := '';
while (i <= Num) or (system.Length(Result) < Length) do begin
if Num and i = i then
Result := '1' + Result
else
Result := '0' + Result;
i := i * 2;
end;
end;
function FastIntToBin(Num: cardinal; Length: integer): string;
var
i: cardinal;
begin
i := 1;
Result := '';
while (i <= Num) or (system.Length(Result) < Length) do begin
if Num and i = i then
Result := '1' + Result
else
Result := '0' + Result;
i := i * 2;
end;
end;
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
