# What is a XOR Logic Gate? (Exclusive OR Gate)

In digital electronics there are special gates. One of them is the **XOR Logic Gate** or Exclusive OR Gate. The image below shows the symbol of a 2-input XOR Logic Gate. Understanding the operation of this digital gate is very important to later be able to implement what is called a digital comparator.

The second image below shows the truth table of a 2-input XOR gate. This gate is represented by the following Boolean function: X = A.B + A.B. Unlike the OR gate, the XOR gate has an output equal to “0” when its inputs are equal to 1.

If you compare the truth tables of the OR gate and the XOR gate it is observed that the XOR gate has a logical “1” in its output when the sum of the logical “1” in the inputs equals an odd number.

The equation can be written in two ways: X = A.B + A.B . or . The following image shows the truth table of a 2-input XOR gate.

Two-input XOR gate truth table

In the same way as in the previous case, it can be seen that X = 1 only when the sum of the inputs equals an odd number.

Three-input XOR gate truth table

## Equivalent XOR Logic Gate Circuit

You can also implement the XOR gate with a combination of basic gates. The following diagram shows a two-input XOR gateway implemented with basic gates: the AND logic gate, the OR logic gate, and the NOT gate.

Equivalent XOR Logic Gate Circuit

Compare this image with the above formula: X = A.B + A.B .

## 3-way Switch using the XOR Gate

One of the uses of the XOR gate is in the 3-way switch, which is used in some long hallways to control the lights from both sides. In a truth table, every change no matter which input, always change the output.