Hamming distance between 1011010 and 1001110 — Hamming code

corecount the differing positions

Answer

2

Why this example is worth doing

The distance is the number of positions where two words differ, computed by XORing them and counting the 1s — the same operation as the XOR difference mask on the XOR gate page. The page connects distance to capability with the two rules that matter: a code with minimum distance d detects d − 1 errors and corrects the integer part of (d − 1)/2, which is why the (7,4) code with distance 3 corrects one.

Try your own input in the Hamming code. Encode, inject an error, and watch the syndrome point straight at the flipped bit.

How the answer is reached

Differing positions

a1011010

b1001110

2 of 7 positions differ, so the Hamming distance is 2.

Compare with

Open the Hamming code

This input is entered in the tool itself — it is too rich for a link to carry.

Note:

Notation this page assumes

  • Bit strings are written most significant bit first, and bit 0 is the least significant bit.
  • A width is stated explicitly wherever it changes the answer; nothing is silently sign-extended or truncated.
  • Hamming positions are numbered from 1 at the left, and parity bits sit at the powers of two — positions 1, 2, 4, 8.

Sources

  • Hamming, “Error Detecting and Error Correcting Codes” (1950)