Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

XOR gate: truth table and symbol

An XOR gate is a logic gate that outputs 1 when its two inputs are different, and 0 when they are the same. Here are its symbol, its full truth table, the boolean expression, and how it is actually built.

The XOR gate symbol: the OR gate's shield shape with an extra curved line just behind it, on the input side.

XOR gate truth table

ABY
000
011
101
110

Boolean expression: Y = A ⊕ B. A 1 in the table means a high voltage (logic true) and a 0 means low (false). Read each row as: for these inputs, the output Y is this value.

Try the XOR gate live

Click A and B to toggle them and watch Y follow the table above. It runs the real simulator, and every row is checked before the page is built.

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “XOR gate”, https://digiwleea.wleeaf.dev/tools/truth-tables/xor/

3-input XOR gate truth table

ABCY
0000
0011
0101
0110
1001
1010
1100
1111

A 3-input XOR gate outputs 1 when an odd number of inputs are 1 (one or all three), which makes it a parity generator: it is two 2-input XORs in a chain.

4-input XOR gate truth table

ABCDY
00000
00011
00101
00110
01001
01010
01100
01111
10001
10010
10100
10111
11000
11011
11101
11110

A 4-input XOR gate outputs 1 when an odd number of inputs are 1 (one or three), in 8 of the 16 rows: it is the parity bit of the four inputs.

What the XOR gate does

XOR (exclusive OR) is the heart of binary addition: the sum bit of a half adder is just A XOR B. It is also a controllable inverter, which is why it shows up everywhere from adders to parity checks to the ALU.

Build it yourself

Reading a table is one thing; watching the signals flow is another. Open the logic gate simulator and wire an XOR gate up from transistors, or read how the XOR gate works in CMOS. You can also generate the table for any expression with the truth table generator.

On a breadboard, four XOR gates come in one chip, the 7486 (74LS86, 74HC86): see its pinout and try every gate live. Without an XOR chip, build it from other gates: XOR from AND, OR and NOT (A'B + AB'), from four NAND gates or from five NOR gates.

Other gates (or all seven symbols and truth tables on one page):

The XOR gate is one small step toward a working CPU. Build every gate from CMOS transistors and work up to an 8-bit processor in the free digiwleea lab, with the free theory reference alongside.

Open the gate simulator →

Frequently asked

What is an XOR gate?

An XOR gate is a logic gate that outputs 1 when its two inputs are different, and 0 when they are the same.

What is the truth table of an XOR gate?

The XOR gate outputs 1 when its two inputs are different, and 0 when they are the same. For inputs (A,B) the outputs are 0,0→0 0,1→1 1,0→1 1,1→0.

What does the XOR gate symbol look like?

It is drawn as the OR gate's shield shape with an extra curved line just behind it, on the input side.

What is the truth table of a 3-input XOR gate?

A 3-input XOR gate outputs 1 when an odd number of inputs are 1 (one or all three), which makes it a parity generator: it is two 2-input XORs in a chain.

What is the truth table of a 4-input XOR gate?

A 4-input XOR gate outputs 1 when an odd number of inputs are 1 (one or three), in 8 of the 16 rows: it is the parity bit of the four inputs.

What is the boolean expression for XOR?

The XOR gate is written Y = A XOR B (symbolically Y = A ⊕ B).

How many transistors does an XOR gate take?

A CMOS XOR gate takes about 8 transistors when built from two inverters and two transmission gates, or 12 as a fully complementary static gate (an AND-OR-INVERT plus input inverters). In digiwleea you build it from transistors and the simulator verifies it against this exact truth table.

Which IC is an XOR gate?

The 7486 (74LS86, 74HC86) chip holds four XOR gates in one 14-pin package; its pinout runs live on the 7486 page.

What is the difference between an XOR gate and an OR gate?

XOR outputs 1 only when its inputs differ; OR also outputs 1 when both inputs are 1. That one row, 1 and 1, is the whole difference.

What is the XOR gate used for?

It is the sum bit of a binary adder, the core of parity generators and checkers, and a controlled inverter (A XOR 1 = NOT A). Its inverse, XNOR, tests two bits for equality.

What is the formula of an XOR gate?

Y = A XOR B = A'B + AB': the output is 1 when exactly one input is 1. An equivalent form is (A + B)(AB)', which reads as "A or B, but not both".

How is XOR written in code?

C, C++, Java, JavaScript, Python and Verilog write bitwise XOR as A ^ B; VHDL writes A xor B. On single bits it gives the same table as the gate.