juniorBit Manipulation
Explain the XOR (^) operator's unique property.
Updated Apr 28, 2026
Short answer
Any number XORed with itself is 0, and XORed with 0 is itself.
Deep explanation
Bit manipulation at the hardware level is faster than arithmetic. Any number XORed with itself is 0, and XORed with 0 is itself. This is fundamental for low-level optimization.
Real-world example
Flag management in simple game engines.
Common mistakes
- Forgetting that bitwise operators have lower precedence than comparison operators.
Follow-up questions
- What is 1 << 3?