XNOR Calculator

Compare two numbers bit by bit and get a 1 in every column where they agree.

Operand A
Operand B
XNOR result
Runs locally in your browser

About the XNOR Calculator

XNOR is the equality gate. Each column of the answer is 1 when both operands carry the same value there, whether that value is 0 or 1, and 0 when they differ. A result made entirely of ones therefore means the two operands are identical, which is how a hardware comparator is built: XNOR each pair of bits, then AND the lot together.

That also makes XNOR the quickest way to see how far apart two configuration words are. Every 0 in the result marks a position where the two words disagree, so the count of zeros is the Hamming distance between them. Reading the bit layout is often faster than diffing two hexadecimal strings by eye.

Enter values as decimal or with a 0x, 0b or 0o prefix, or pin the input base to read a pasted column consistently. Because the result is inverted, the word size shows up in the answer: with the width on Auto the narrowest of 8, 16, 32 or 64 bits that fits both operands is used, and the chosen width is printed above the layout. Extra lines in a pane are folded left to right. The output carries decimal, binary, hex and octal readings plus the signed interpretation. For the disagreement version of the same comparison use the XOR Calculator, and to invert a single value use the NOT Calculator.

How to use

  1. Put the first word in the Operand A pane and the word you are comparing it against in Operand B.
  2. Pin a bit width if the two words come from a fixed size register.
  3. Count the zeros in the binary result to get the number of differing bits.
  4. Copy or download the breakdown to attach to a bug report.

Common questions

Why does 12 XNOR 10 give 249?
In binary the two are 00001100 and 00001010. They agree in six columns, and inverting the XOR result 00000110 inside eight bits gives 11111001, which is 249.
How do I read the Hamming distance from this?
Count the 0 bits in the binary line. Each one marks a position where the operands differ, and that count is the Hamming distance.
Is XNOR the same as an equality test?
Per bit, yes. For whole numbers you still need every column to be 1, which is why a comparator ANDs the XNOR outputs together.
Does XNOR have an operator in C or JavaScript?
No. Neither language has one, so it is written as the bitwise complement of an exclusive or, spelled ~(a ^ b).