Skip to main content


Home Hamming code

Hamming code

Hamming code definition

Hamming code is a type of linear error-correcting code that adds extra bits to data in order to detect errors resulting from transmission. Hamming code is block code, meaning it operates on fixed-size blocks of data. The Hamming code system was developed by Richard Hamming in the 1950s.

See also: odd parity, even parity, parity check, error correction code

How Hamming code works

Hamming code uses parity to check for errors. The encoding process adds parity bits to the data, with the value of the parity bit chosen to ensure that the total number of bits set to 1 (including the parity bit) is either even (even parity) or odd (odd parity).

These parity bits are checked during the decoding process — if there was an error in transmission, the parity (even or odd) will be incorrect. Based on the parity information, we can identify the position of the incorrect bit and correct single-bit errors.

Hamming codes have a specific minimum Hamming distance (the number of positions between two binary strings at which the corresponding bits are different) for error detection. This distance value determines how many errors the code can detect and correct — for example, Hamming code with a minimum distance of three can detect up to two errors and correct one error.