十进制转二进制串
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;
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;