XOR Gate Explained: Truth Table and Logic Demo
An XOR gate outputs 1 when its inputs differ. Compare its four truth-table rows and experiment with a live XOR mini-demo.
How an XOR gate works
XOR means exclusive OR. For two inputs, the output is 1 when exactly one input is 1, which is the same as saying the inputs are different. If both inputs match—0,0 or 1,1—the output is 0. The Boolean expression is Y = A ⊕ B. The truth table is similar to an OR gate but differs on the final row: ordinary OR outputs 1 for two high inputs, while XOR outputs 0.
XOR is a combinational logic gate with two or more possible inputs and no memory. It can also be written as (A · ¬B) + (¬A · B), which shows the two cases that make the output true. That expression is useful when building XOR from simpler AND, OR, and NOT gates, or when checking an XOR circuit by its truth table.
XOR in adders and digital systems
XOR is central to binary arithmetic. In a half adder, the XOR output is the Sum bit, while an AND gate produces Carry. For example, 1 + 1 has a sum of 0 and a carry of 1. XOR also appears in parity checks, where toggling one bit changes the parity result, and in comparison circuits that detect whether two bits are unequal.
The mini-demo lets you toggle both inputs and see the XOR output and truth table together. Try each pair, then compare the result with OR. To explore a larger circuit, open the free online logic gate simulator and build XOR from basic gates or use it in the half-adder mission. Testing all input combinations is a simple way to verify both your design and your understanding.
XOR truth table
Boolean expression: Y = A ⊕ B
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Use the interactive controls on this page to toggle the inputs and see the output change.
Frequently asked questions
What does XOR mean?
XOR means exclusive OR. It outputs 1 when exactly one input is 1, or equivalently when the two inputs differ.
How is XOR different from OR?
OR is true if one or both inputs are 1. XOR is true only when the inputs differ, so XOR outputs 0 for inputs 1,1.