XNOR gate

The gate that fires when its inputs agree — the equality detector. A plain-English guide to logic gates from TorchAnvil.

An XNOR gate is XOR with the answer inverted. Its output is high when its inputs agree — both off, or both on. It is the equality detector.

How to read it

A B A ⊙ B
0 0 1
0 1 0
1 0 0
1 1 1

Two 1s on the diagonal. Where XOR asks "are these different?", XNOR asks "are these the same?" — and for single bits, "the same" and "equal" are the same question. That's why XNOR is usually just called the equivalence gate.

Why it matters

Comparison is the killer application. To test whether two multi-bit numbers are equal, XNOR each pair of bits and AND all the results together. If every bit agrees, every XNOR outputs 1, and the AND fires.

That circuit is inside every processor, running on every branch instruction you've ever executed. if (x == y) compiles down to something with this exact shape.

The dual approach uses XOR and a NOR: XOR each pair, then NOR the lot, so the output is high only when no pair differs. Same answer, and often cheaper depending on which gates you have.

A worked example: a 2-bit comparator

Compare A₁A₀ with B₁B₀. Four inputs, one output that should be high exactly when the two 2-bit numbers match.

  1. E₀ = A₀ ⊙ B₀ — do the low bits agree?
  2. E₁ = A₁ ⊙ B₁ — do the high bits agree?
  3. Equal = E₀ · E₁

Test it with A = 10 and B = 10: both XNORs output 1, the AND outputs

  1. Now try A = 10, B = 11: the low bits differ, E₀ is 0, and the AND drops. Correct.

Widening this to 8 or 32 bits changes nothing structurally — you just add more XNORs and a wider AND. That scalability is why comparators are among the easiest real circuits to build once you've understood one bit of it.

The parity connection

XNOR is even parity. Chain XNORs across a word and the output tells you whether the number of 1s is even, where a chain of XORs tells you whether it's odd.

Parity is the simplest error-detecting code there is: send a word plus a parity bit, and a single flipped bit anywhere is detectable at the far end. It can't tell you which bit flipped, and two flips cancel out — but for one extra wire it's a genuine bargain, and serial protocols used it for decades.

Careful with chains, though. XNOR is associative in the sense that (A ⊙ B) ⊙ C equals A ⊙ (B ⊙ C), but the result of a long XNOR chain is not simply "an even number of inputs are high" — it alternates with the number of gates. If you want a specific parity, build the chain with XORs and invert once at the end. That's easier to reason about and easier to debug.

How it differs from XOR

They are exact complements — every row is flipped:

A B XOR XNOR
0 0 0 1
0 1 1 0
1 0 1 0
1 1 0 1

XOR detects difference; XNOR detects sameness. Pick by what your circuit should do when the inputs agree — if that's the interesting case, you want XNOR.

In redstone

XNOR is the most expensive gate in this palette to build in Minecraft, because it's an XOR — already the awkward one — plus an inversion.

The practical build is the standard XOR pattern with a torch on the output. If you're comparing several bits, invert once at the end rather than per bit: build the comparison from XORs, merge them into a single dust line (a free OR), and put one torch on the result. That gives "no bits differ" with a single inversion instead of one per bit, and it's substantially smaller.

Building it from other gates

Scaling the comparator

The 2-bit comparator above extends to any width without a single new idea: one XNOR per bit pair, then one wide AND.

For an 8-bit comparison that's eight XNORs and a 8-input AND. Built as a chain the AND is seven gates deep; built as a tree it's three. Same logic, less than half the delay — the same trade-off described in the OR guide.

There's one more identity worth knowing here. Because NOT(A ⊕ B) = A ⊙ B, an equality test can be written either way round:

They produce identical outputs. Which is cheaper depends entirely on your gate costs, and in redstone the second wins comfortably.

Gotchas

Try it

The demo on the right is two levers into an XNOR into a lamp. The lamp is lit when the levers match — both up or both down — and dark when they disagree.

Then build the 2-bit comparator above: four levers, two XNORs, one AND, one lamp. It's the smallest genuinely useful circuit on this site.

Frequently asked questions

What is an XNOR gate?
An XNOR gate outputs high when its inputs agree — both off or both on — and low when they differ. It is XOR with the output inverted, and is often called the equivalence gate.
What is an XNOR gate used for?
Comparing values. XNOR each pair of bits from two numbers and AND the results, and the output is high only if every bit matches. That circuit sits behind every equality test a processor performs.
What is the difference between XNOR and NOR?
NOR is high only when both inputs are low. XNOR is high when both are low and also when both are high. They agree on just one row of the truth table out of four.
Is XNOR the same as even parity?
For two inputs, yes — it is high when an even number of inputs are high. For longer chains the relationship alternates with the gate count, so it is safer to build parity from XORs and invert once at the end.
How do you build an XNOR gate in Minecraft redstone?
Build the standard XOR pattern and put a redstone torch on its output to invert it. When comparing several bits, merge the XOR outputs onto one dust line and invert once, rather than inverting each bit separately.