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.
| 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.
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.
A = B (4-bit) = (A₀ ⊙ B₀) · (A₁ ⊙ B₁) · (A₂ ⊙ B₂) · (A₃ ⊙ B₃)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.
Compare A₁A₀ with B₁B₀. Four inputs, one output that should be high
exactly when the two 2-bit numbers match.
E₀ = A₀ ⊙ B₀ — do the low bits agree?E₁ = A₁ ⊙ B₁ — do the high bits agree?Equal = E₀ · E₁Test it with A = 10 and B = 10: both XNORs output 1, the AND outputs
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.
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.
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.
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.
A ⊙ B = NOT(A ⊕ B)A ⊙ B = (A · B) + (NOT A · NOT B) — "both on, or both off", read
straight off the two rows where the output is 1A ⊙ B = (A + NOT B) · (NOT A + B) — the product-of-sums formThe 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.
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.