11011110和11111111按位逻辑与运算后结果为11011110 怎么得到的?
解决方案 »
- delphi 怎么实现机构图的显示与打印
- 就等你了...
- 如果检查adotable中是否有需要保存的数据?即adotable中是否添加或者修改了数据并且尚未保存?
- 每天24:00从远程服务器上拷贝文件到本地,怎么做?
- 1000元现金急求!把TXT和RDB文件中文本自动上传到网上数据库中的小程序
- 怎样在企业管理器里面用ms sql的时间函数,
- 我失业了,在深圳,这里都是要java,悲惨!散分!
- UDP是不分SERVER和CLIENT的,那为什么还有IDUDPSERVER和IDUDPCLIENT??
- 简单的SQL求助!
- 在delphi下运行程序时,有时候会出现Access violation at address 77FA1032 in module 'ntdll.dll'. Write of address 00000030错误
- rave报表,如何不显示选择画面直接打印。
- 怎麽樣修改查詢值 高手??
A,B,C : Byte;
begin
A := 222;//每个二进位用二进制表示就是11011110
B := 255;
C := A and B;
Showmessage(IntToStr(C));//222
end;你不会是想得到11011110这样的字符串吧?其实也很简单的
{$R *.dfm}function AndBinStr(const S1, S2: string): string;
//用二进制字符串表示的两个数按位与后返回二进字符串
var I, L : integer;
begin
Result := '';
L := Min(Length(S1),Length(S2));
for I := 1 to L do
Result := Result + IntToStr(StrToInt(S1[I]) and StrToInt(S2[I]));
end;procedure TForm1.Button1Click(Sender: TObject);// 测试
var
S1, S2 ,S : string;
begin
S1 := '11011110';
S2 := '11111111';
S := AndBinStr(S1,S2);
Showmessage(S);
end;
如果进行与运算,即对应的位进行与
//1 and 1=1
//0 and 1=0
//1 and 0=0
1 1 0 1 1 1 1 0
and and and and and and and and
1 1 1 1 1 1 1 1
=
1 1 0 1 1 1 1 0
function IntToBin(A:Integer):string;
var
i:Integer;
begin
for i:=0 to SizeOf(Integer)*8-1 do
begin
Result:=IntToStr((A shr i) and 1)+Result;
end;
end;