LogicGates.org Open the simulatorSimulator

XNOR gate

High when its two inputs agree.

Truth table

ab Q
0 0 1
0 1 0
1 0 0
1 1 1

At a glance

Boolean expression
¬(a ⊻ b)
Engineering notation
(a ⊕ b)'
Inputs
Two
Output is high when
its two inputs are equal

How the XNOR gate behaves

An exclusive NOR gate outputs 1 when its two inputs are the same, both 0 or both 1, and 0 when they differ. It is an XOR gate with the output inverted, which makes it a one bit equality detector. Because of that it is also called the equivalence gate, and written a ≡ b or a ⊙ b.

Where XOR asks "are these two different?", XNOR asks "are these two the same?". That is the question a processor puts to every pair of bits when it compares two numbers, so a comparator is a row of XNOR gates feeding an AND. XNOR is not universal though: chain XORs and XNORs however you like and the result still only ever counts whether an odd or even number of some of its inputs are high, so AND and OR are out of reach without another gate.

Building it from other gates

Each of these is equivalent to the XNOR gate. Paste any of them into the simulator with ctrl+E to see the circuit.

Construction Expression Equals
XOR, inverted !(a ^ b) (a & b) | (!a & !b)
Sum of products (a & b) | (!a & !b) !(a ^ b)
Product of sums (a | !b) & (!a | b) !(a ^ b)
XOR with one input inverted a ^ !b !(a ^ b)
From NAND gates only !(!(a & !(a & !(b & b))) & !(!(b & b) & !(a & !(b & b)))) !(a ^ b)

Reference card

The symbol in both standards and the truth table on one image, for notes or a slide.

XNOR gate reference: ANSI and IEC symbols, the boolean expression ¬(a ⊻ b), and the full truth table Click to download the XNOR reference card

Where the XNOR gate is used

  • One bit of an equality comparator: a XNOR per bit pair, then an AND across them, says whether two words are identical.
  • The final stage of an even parity checker: XOR the data bits together, then XNOR the result with the received parity bit: the output is high when they match, so a 0 means a bit was flipped.
  • A controlled buffer: XNOR a signal with 1 to pass it unchanged, or with 0 to invert it, the opposite sense to XOR.
  • Counting matching bits between two patterns, which is how correlators and binary neural networks score a match: XNOR each pair, then count the 1s.

In the simulator

There is no XNOR node in the simulator. Place an XOR and feed its output into a NOT, or put the NOT on one of the XOR inputs instead, which gives the same table. Package the pair as a custom node and it behaves like a native gate.

Open the simulator

Questions about the XNOR gate

What is the difference between XOR and XNOR?

They are opposites on every row. XOR outputs 1 when its two inputs differ; XNOR outputs 1 when they are the same. XNOR is exactly an XOR gate followed by a NOT gate, which is what the N in the name and the bubble on the symbol mean.

Is XNOR a universal gate?

No. NAND and NOR can each build every other gate, but XNOR cannot, and neither can XOR. Any circuit made only of XOR and XNOR gates still only reports whether an even or odd number of its inputs are high, however it is wired, so it can never behave like an AND or an OR. Add an AND gate to XOR and XNOR together and the set becomes complete: XNOR of a signal with itself supplies a constant 1, and XOR with 1 is NOT.

How many NAND gates does XNOR need?

Five. XOR takes four NAND gates, and XNOR is XOR with either the output or one of the inputs inverted, which is one more NAND with its inputs tied together. That is one more than XOR and three more than AND, so in NAND-only designs an equality test is comparatively expensive.

Why is XNOR called the equivalence gate?

Because its output is 1 precisely when the two inputs are equivalent, both 0 or both 1. In logic notation that is a ≡ b or a ⊙ b, and in a comparator that is the "these two bits match" signal.

The other gates