◎◎◎ Delphi 中如何把 Byte 转换为二进制数据,保存于数组中?

bigsail 2007-06-16 06:44:53
如何把 Byte 数据转换为二进制数据,并保存于数组中?

然后,我读取数组中的0/1数据来进行具体的处理。

有能力者请给出示例代码!!!
...全文
503 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hongqi162 2007-06-16
  • 打赏
  • 举报
回复
var
b: Byte;
s: string;
IntI: Integer;
function ByteToBin(Value: Byte): string;
const
V: Byte = 1;
var
i: Integer;
begin
for i:= 7 downto 0 do
if (V shl i) and Value <> 0 then
Result := Result + '1'
else
Result := Result + '0';
end;
begin
b:= $c;
s:= ByteToBin( b );
for IntI:= 1 to Length( s ) do
begin
self.ListBox1.Items.Add( s[ IntI ] );
end;
end;
hongqi162 2007-06-16
  • 打赏
  • 举报
回复
function ByteToBin(Value: Byte): string;
const
V: Byte = 1;
var
i: Integer;
begin
for i:= 7 downto 0 do
if (V shl i) and Value <> 0 then
Result := Result + '1'
else
Result := Result + '0';
end;

828

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧