delphi 一个整数转其二进制表示的小函数


本文整理自网络,侵删。

 
function IntToBinStr(v: Integer): String;
var
  b: array [0 .. 32] of Char;
  o: Integer;
const
  Chars: array [0 .. 1] of Char = ('0', '1');
begin
  o := 31;
  if v <> 0 then
  begin
    while v <> 0 do
    begin
      b[o] := Chars[v and $1];
      v := v shr 1;
      Dec(o);
    end;
    b[32] := #0;
    Result := PChar(@b[o + 1]);
  end
  else
    Result := '0';

end;

 

来源:http://blog.qdac.cc/?p=3443

相关阅读 >>

Delphi 从字符串提取字符串

Delphi txt日志log

Delphi integer.tryparse

Delphi 存储文件到数据库

Delphi edgebrowser1 浏览器实现控制滚动条

Delphi 去字符串长度函数 strlen,length

Delphi tmsweb core webhttprequest1提交json数据

Delphi cef4 忽略不安全网站

Delphi 编写的一个感染文件夹的小病毒

Delphi 当前日期的加减运算

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...