FormatterHQ

XNOR Calculator

Compute the bitwise XNOR of two numbers to see where their bits agree. Results are shown unsigned, signed, in hex, octal and binary for the bit width you choose.

Loading tool…
Ready.

How to use the XNOR Calculator

  1. Type two whole numbers in Operand A and Operand B.
  2. Choose the base of each operand and the bit width (8-bit is preselected).
  3. Read the XNOR result; a 1 bit means the inputs agree at that position.
  4. Copy the value in whichever base you need.

XNOR calculator: find matching bits

This XNOR calculator applies exclusive NOR, the inverse of XOR. Each output bit is set wherever the inputs match, whether both are 0 or both are 1, and cleared wherever they differ, so XNOR acts as a bit-level equality test. It is also called the equivalence gate.

XNOR truth table

ABA XOR BA XNOR B
0001
0110
1010
1101

Worked 8-bit example: 12 XNOR 10

     00001100    (12)
XNOR 00001010    (10)
     --------
=    11111001    (249, signed −7, 0xF9)

The numbers differ in bits 2 and 1, so those are 0 and every other bit is 1. As an unsigned byte that is 249; as a signed byte, −7. In 16 bits the result is 65529 (0xFFF9).

Reading the result

  • Identical inputs give all 1s: 12 XNOR 12 is 255 in 8 bits, or −1 signed. That is a quick equality check.
  • Counting zeros in the result gives the number of differing bits, the Hamming distance.
  • Complement relationship: XNOR plus XOR always covers every bit exactly once, so 249 + 6 = 255 for these inputs in 8 bits.

Counting matching bits

Because every 1 in an XNOR result marks a position where the inputs agree, counting the ones measures similarity. For 12 XNOR 10 in 8 bits, 11111001 contains six ones: six bits match and two differ.

# Python 3.10+: mask to the width, then count
(~(12 ^ 10) & 0xFF).bit_count()    # 6

Binarized neural networks use exactly this trick. When values of +1 and −1 are stored as bits 1 and 0, the dot product of two n-bit vectors equals 2 × (number of matching bits) − n. For the example that is 2 × 6 − 8 = 4, computed with one XNOR and one population count instead of eight multiplications.

Three or more inputs

The calculator takes two operands. For several values, switch the operation to XOR, combine them two at a time and apply NOT to the final result. A bit then comes out as 1 when an even number of inputs have a 1 there, which is the even-parity check used in some error-detection schemes.

Where XNOR shows up

Hardware comparators use one XNOR gate per bit and AND the outputs to decide whether two words are equal. XNOR is also the basic operation in binarized neural networks, where it replaces multiplication of +1/−1 values.

Options

  • Input base: decimal, hex, binary or octal, set separately for each operand; 0x, 0b and 0o prefixes override the setting for a value.
  • Bit width: 8, 16, 32 or 64 bits. Because inversion sets unused high bits, always pick the width of your real data.

To see the differing bits directly, use the XOR calculator. The NOR calculator is a close cousin, and every operation is available in the bitwise calculator.

Frequently asked questions

What is 12 XNOR 10?
In 8 bits it is 249, binary 11111001 or hex F9, and −7 as a signed byte. The two 0 bits mark the positions where 12 and 10 differ.
How do I calculate XNOR in code?
Use ~(a ^ b) and mask to your width when the language has unlimited integers, for example ~(a ^ b) & 0xFF in Python for 8 bits. For single booleans, a == b gives the same truth value as XNOR.
Why is XNOR called an equivalence gate?
Its output is 1 exactly when both inputs are equivalent (the same). In logic it corresponds to "if and only if".
What is the difference between XNOR and XOR?
They are exact opposites. XOR outputs 1 where bits differ, XNOR outputs 1 where they match, so every result bit of one is inverted in the other.

Last updated October 3, 2026

Related tools