Encode data 1011 as Hamming (7,4) — Hamming code

intro3 parity bits, 4 data bits

Answer

0110011

Why this example is worth doing

The canonical (7,4) example. Parity bits occupy positions 1, 2 and 4 — the powers of two — and the data bits fill the rest, so the codeword interleaves them rather than appending a parity block. The tool shows which positions each parity bit covers and the even-parity calculation for each. That interleaved layout is not arbitrary: it is exactly what makes the syndrome point at the error, which the next example demonstrates.

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

Hamming (7,4) encode

Hamming (7,4): 3 parity bits, because 2^3 = 8 ≥ k + r + 1 = 8.

Data word1011

Parity bits occupy the power-of-two positions; the payload fills the rest in order. — Hamming (7,4) encode
PositionBinary indexHoldsBit
1001p10
2010p21
3011d11
4100p40
5101d20
6110d31
7111d41

Each parity bit is the XOR of the data bits it covers, so every check comes out even.

p11 ⊕ 0 ⊕ 1 = 0covers positions 3, 5, 7

p21 ⊕ 1 ⊕ 1 = 1covers positions 3, 6, 7

p40 ⊕ 1 ⊕ 1 = 0covers positions 5, 6, 7

Codeword0110011Highlighted cells are parity bits.

Warning:

Positions are 1-indexed: the first character of the codeword is position 1.

Source: R. W. Hamming, Bell System Technical Journal 29(2):147–160 (1950)

Compare with

Open this example in the Hamming code

The field arrives filled in with this example’s input.

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)