按位异或的问题

来源:百度知道 编辑:UC知道 时间:2024/06/02 18:06:31
(0000 0101)^(0000 1001)=1111 0011
这个答案对吗

按位与(&):
都为1时结果为1,否则为0;

按位或(|):
都为0时结果为0,否则为1;

按位异或(^):
相同为0,不同为1。

所以:(0000 0101)^(0000 1001) = 0000 1100

private void button1_Click(object sender, EventArgs e)
{
string[] s = { "00000101", "00001001" };
int temp1 = Convert.ToInt32(s[0],2);
int temp2 = Convert.ToInt32(s[1],2);
int temp3 = temp1 ^ temp2;

textBox1.Text = Convert.ToString(temp3, 2);
}

自己用这个程序验证
和上面的朋友说的一样
1111 ^ 1001 = 0110

应该是对的.

0 0 ->0
0 0 ->0
0 0 ->0
0 0 ->0

0 1 ->1
1 0 ->1
0 0 ->0
1 1 ->0

1111 ^ 1001 = 0110

异或:相同出0.不同出1.
你说你对不对呢??呵呵

你的操作是同或运算。