你管这玩意叫异或运算？

1.

x ^ x = 0

0 ^ y = y

x ^ y = y ^ x

x ^ 0 = x

2.

1 ^ 2 ^ 3 ^ ... ^ n ^ A[0] ^ A[1] ^ A[2] ^ ... ^ A[n - 2]

1 到 n 的和，可以通过等差数列求和公式直接计算出：

(1 + n) * n / 2 - A[0] - A[1] - A[2] - ... - A[n - 2]

1 ^ 2 ^ 3 ^ ... ^ n ^ A[0] ^ A[1] ^ A[2] ^ ... ^ A[n]

x ^ x ^ x = 0 ^ x = x

3.

int t;x = t;x = y;y = t;


x ^= y;y ^= x;x ^= y;


4.

if(x != y){
x ^= y;
y ^= x;
x ^= y;
}


(x == y) || ((x ^= y), (y ^= x), (x ^= y))


(x ^ y) && (y ^= x ^= y, x ^= y)


(&a == &b) || ((a -= b), (b += a), (a = b - a))


5.

xor same, same


xor reg, reg


https://stackoverflow.com/questions/33666617/what-is-the-best-way-to-set-a-register-to-zero-in-x86-assembly-xor-mov-or-and

What is the best way to set a register to zero in x86 assembly: xor, mov or and?

6.

01101000 01101001


00110110 00110110


01101000 01101001 (密文)异或00110110 00110110 (秘钥)=01011110 01011111 (加密信息)


7.

https://www.linuxjournal.com/article/6828

8.

x ^ y = (!x and y)  or (x and !y)

x and !y 也表示 x 和 y 不同，其中 x1y0




04-13 188

08-18 1089
08-22 36
05-05 21
07-21 68
02-19 619
02-28 652
06-22 1223
07-27 172
06-21 20
10-04 1178
03-15 72
08-02 698
10-25 1611