IntToBin(2-16进制转换函数)
2006-02-04 13:57:13 来源:WEB开发网核心提示:(Value是要转换的十进制数,Count是输出的二进制位数,IntToBin(2-16进制转换函数),默认32位)function IntToBin(Value: Integer; Count: Integer=32): string;var iTemp: Integer;begin Result := '
(****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
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
更多精彩
赞助商链接