IntToBin(2-16进制转换函数)

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 imustworkhard 的 blog

(****value是要转换的十进制数,count是输出的二进制位数,默认32位****)
function inttobin(value: integer; count: integer=32): string;
var
  itemp: integer;
begin
  result := '';
  while count>0 do
  begin
    itemp := value shr (count-1) and 1;
    case itemp of
      1: result := result+'1';
      0: result := result+'0';
    end;
    dec(count);
  end;
end;
自己写的,不知有否漏洞,测试了一下
showmessage(inttobin(-1,8));  //输出11111111
showmessage(inttobin(333333)); //输出00000000000001010001011000010101

本文关键:IntToBin(2-16进制转换函数)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top