Beetwise

Bitwise XNOR

XNOR is an XOR with the result inverted.

A bit of the result has the value 1 when the two inputs agree at that position.

XNOR is the equality test of two bits.

Try bitwise XNOR in the bit editor

The result of 12 XNOR 10 in an 8-bit register. Edit the expression or select a bit to flip it.

7
6
5
4
3
2
1
0
-7
value · 8 bits · signed
hex
0xF9
Read the bits as

The truth table of XNOR

The truth table of XNOR
ABA XNOR B
001
010
100
111

Where bitwise XNOR is used

A comparator circuit uses XNOR for each bit pair.

A parity check and a checksum both rest on XOR and its inverted form.

A search for the bits that two register values share uses XNOR.

Bitwise XNOR: points to note

  • The result depends on the bit width, because the NOT part fills every bit above the operands.
  • An XNOR of a value with itself gives every bit with the value 1.
  • Beetwise marks the entry as signed, because the raw result of NOT is negative.
  • A logical equality test on whole values is ==, not XNOR. XNOR compares each bit.

The full bit editor

The full editor holds many values, evaluates expressions across them, and reads live values from a serial port.

Open this value in the full editor

Questions about bitwise XNOR

What is 12 XNOR 10?
In 8 bits the result is 249. The XOR gives 6, and the NOT of 6 gives 249 in 8 bits.
How do I write XNOR in C?
Write ~(a ^ b), then mask the result to the width you need.
What does XNOR report?
It reports the positions where the two values agree. A bit with the value 1 marks a match.