Question 2
Back to Exercise
For any integer x, what is x ^ x?
- A x
- B 0 Correct
- C 1
- D 2 * x
Correct Answer: Option B
XOR gives 1 only where the bits differ, and a number never differs from itself. This "cancelling" property is behind the find-the-single-number trick and simple checksums.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!