Advertisement
WarPie90

IntToBinary

Sep 23rd, 2014
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.28 KB | None | 0 0
  1. function IntToBin(i:Int64; bits:Int32=8): String; //bits:8,16,32,64
  2. var c:Int8;
  3. begin
  4.   for c:=bits-1 downto 0 do
  5.     Result += ToStr((i shr c) and 1);
  6. end;
  7.  
  8. begin
  9.   WriteLn('>> ', IntToBin(13));
  10.   WriteLn('>> ', IntToBin(34));
  11.   WriteLn('>> ', IntToBin(13 or 34));
  12. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement