The special nature of AND operation, XOR operation

The nature of the AND operation (&):

  1. For any integer x, let x = x & (x-1), this operation can change the last 1 in the binary representation of x to 0.

The nature of the exclusive OR operation (⊕):

  1. Any number and 0 are XORed, the result is still the original number, that is, a ⊕ 0 = a.
  2. If any number is XORed with itself, the result is 0, that is, a ⊕ a = 0.
  3. The exclusive OR operation satisfies the commutative and associative laws, that is, a ⊕ b ⊕ a = b ⊕ a ⊕ a = b ⊕ (a ⊕ a) = b ⊕ 0 = b.

Guess you like

Origin blog.csdn.net/qq_43665244/article/details/114710341