Introduction to XOR
Explore the bitwise XOR operator, understanding how it compares bits between two operands and outputs results based on their differences. This lesson helps you grasp XOR logic through truth tables and its applications useful for coding interviews.
We'll cover the following...
We'll cover the following...
What is the Bitwise XOR operator?
This operator is same as the XOR gate that we studied in the digital electronics chapter, as shown below:
Bitwise XOR operator is denoted by ^. When an XOR gate is given with 2 inputs, the corresponding outputs will be:
- If two input bits are different, the output is 1.
- In all other cases,