XNOR and Bit Equality
← All articles

XNOR and Bit Equality

4 min

The mirror image of XOR

XOR outputs 1 when its inputs differ; XNOR is its exact complement — XNOR(A,B) = ¬(A⊕B) — outputting 1 when A and B are equal (both 0 or both 1) and 0 when they differ. It's sometimes called the 'equivalence' or 'coincidence' gate for exactly this reason.

One gate, one bit-equality test

Two matching cases, two mismatching cases:

  • XNOR(0,0) = 1 and XNOR(1,1) = 1 — matching bits.
  • XNOR(0,1) = 0 and XNOR(1,0) = 0 — mismatched bits.
  • Comparing two multi-bit numbers is exactly N XNOR gates, one per bit position, followed by an AND of all N outputs — the AND is 1 only if every single bit pair matched.

Where it already shows up

Boolflow's comparator blocks use exactly this XNOR-then-AND structure internally to compute their equality output, and a parity check on the receiving end of a transmission is really just XNORing the received parity bit against a freshly recomputed one — a mismatch signals a corrupted bit.

Try it yourself

Build a 4-bit equality checker in the circuit editor from four XNOR gates feeding one AND4, wire two 4-bit groups of INPUT switches into it, and confirm with the Truth Table tool that the output is 1 for exactly the 16 cases where both inputs are identical.

Compare two bits with an XNOR gate →