History of Math

Hamming Codes and Self-Correcting Bits

Richard Hamming’s 1950 codes added parity bits to data so a receiver could detect and correct a single flipped bit. Toggle four data bits, flip any of the seven encoded bits, and watch the syndrome reveal the error position.

6 minLevel 3/3The interactive stage stays ad-free.
Data bits1011Codeword0110011Syndrome000 (ok)Error positionnoneRepaired—
Data bits — click to toggle7-bit Hamming(7,4) codeword — click a bit to flip an error
data parity (positions 1, 2, 4) flipped bit syndrome hit

even parity · syndrome = XOR of positions with a 1 = 0 → no error detected

No error detectedThe received codeword 0110011 is valid.
Richard Hamming, Bell Labs, 1950Hamming devised these codes after watching punched-card machines halt on a single error. The parity bits at positions 1, 2, and 4 encode the binary address of a flipped bit, so one bit can be located and corrected. Two flipped bits can produce a syndrome that points to the wrong position, so this scheme corrects single-bit errors only.

Four data bits are placed at positions 3, 5, 6, and 7. Parity bits at 1, 2, and 4 are computed with even parity. Click any encoded bit to inject a single error; the syndrome is the XOR of the positions holding a 1, which directly names the corrupted position. If two bits flipped at once, the syndrome would point at a third position — that is why Hamming(7,4) only guarantees single-bit correction.

What you are seeing

1

Four data bits sit at positions 3, 5, 6, and 7 of a 7-bit word. Positions 1, 2, and 4 hold parity bits computed from overlapping subsets.

2

Each parity bit makes its subset have even parity. When a bit flips, the subsets containing it break parity.

3

The syndrome is the XOR of the positions holding a 1. A nonzero syndrome names the corrupted position, so flipping it back repairs the word.

Why it matters

Error-correcting codes keep data intact in memory, storage, and communication. Hamming’s idea is the ancestor of the ECC in RAM and the coding schemes used in networking and space probes.

Complexity & details

Encoding and syndrome checking are O(n) for n = 7 bits. Correcting one error is O(1) after the syndrome is known.

Frequently asked questions

Can it fix two flipped bits?+

No. With two flipped bits the syndrome is the XOR of two positions, which points somewhere else, so the correction can be wrong. Hamming(7,4) guarantees only single-bit correction, though it can detect some double-bit errors.

Why are parities at positions 1, 2, and 4?+

Those are the powers of two, so their binary representations are single 1 bits. Grouping positions by which of these bits is set makes the syndrome equal to the error position.