%3C/text%3E%3C/svg%3E">
💻
💻 Tech & IT

Hamming Code Calculator (encode data bits, find & correct a 1-bit error)

Results update as you type.

Your numbers

Understanding the Hamming code calculator — concept and principle

Hamming codes add a few check bits to data so that a single flipped bit can be found and corrected. This calculator encodes data bits into a Hamming codeword, or checks a received codeword, computes the syndrome and corrects a single-bit error. It is a classic topic in computer science, digital communications and memory design.

Hamming code layoutHamming (7,4) encoding of 101110p121p231d40p450d61d71dp1 = d3 ⊕ d5 ⊕ d7 = 1 ⊕ 0 ⊕ 1 = 0p2 = d3 ⊕ d6 ⊕ d7 = 1 ⊕ 1 ⊕ 1 = 1p4 = d5 ⊕ d6 ⊕ d7 = 0 ⊕ 1 ⊕ 1 = 0Codeword 0110 011Parity bits sit at powers of two: 1, 2, 4
Three parity bits at positions 1, 2 and 4 protect the four data bits.

How it is calculated

Positions are numbered from 1. Positions 1, 2, 4, 8 … hold check bits; data bits fill the rest in order.

Check bit p covers every position whose binary number includes p, and is set to make that group's count of 1s even.

Number of check bits k: the smallest k with 2^k ≥ m + k + 1 for m data bits.

Checking: XOR together the positions of all 1s; the result is the syndrome. 0 means no error found; otherwise it is the position of a single wrong bit.

The principle

Each position has a binary number, and each check bit watches the positions sharing one binary digit. If one bit flips, exactly the checks that cover its position fail. Reading the failed checks as binary digits spells out the position number, which is why the syndrome points directly to the error. With k check bits there are 2^k possible syndromes, enough to name any of the m + k positions or "no error". A plain Hamming code corrects one error; two errors produce a wrong correction.

Worked example

Default inputs: encode data bits 1011.

  1. m = 4 data bits; k = 3 because 2³ = 8 ≥ 4 + 3 + 1. Code = (7, 4).
  2. Data go to positions 3, 5, 6, 7: 1, 0, 1, 1.
  3. p1 covers 3, 5, 7: 1 ⊕ 0 ⊕ 1 = 0; p2 covers 3, 6, 7: 1 ⊕ 1 ⊕ 1 = 1; p4 covers 5, 6, 7: 0 ⊕ 1 ⊕ 1 = 0.
  4. Codeword (positions 1–7) = 0110 011; data bits = 1011.
  5. No check is performed in encode mode, so error position and syndrome show —.

How to read the result

Send or store the codeword. When checking, a syndrome of zero means no single-bit error was found; a non-zero syndrome within the word length gives the bit to flip back. Practical memory systems often add one more overall parity bit (SECDED) so that double errors can be detected rather than miscorrected.

Common mistakes

Keep in mind: A plain Hamming code corrects only one error per codeword. Systems that face burst errors use stronger codes and interleaving.

Frequently asked questions

What does (7, 4) mean?

7 total bits carrying 4 data bits, with 3 check bits.

How is the error position found?

XOR the positions of all 1 bits; the result is the syndrome, the position of the error.

Can Hamming codes detect two errors?

Not reliably on their own; adding an overall parity bit (SECDED) allows detection.

Where are Hamming codes used?

In memory error correction and teaching, and as a foundation for more advanced codes.

Sources: R. W. Hamming, "Error Detecting and Error Correcting Codes", The Bell System Technical Journal 29(2): 147–160, 1950

Checked 9 Nov 2026. R. W. Hamming, “Error Detecting and Error Correcting Codes”, The Bell System Technical Journal 29(2):147–160, April 1950, §3: check positions 1, 2, 4, 8 …, even parity checks, 2^k ≥ m + k + 1, and the checking number giving the position of a single error (example 0111000 → position 5).

💻 All tech & IT tools →🌍 Calculators by country →