How to use the Hamming Code Calculator
- 1. Pick a modeEncode data, or check and correct a received codeword.
- 2. Enter the bitsAnd choose even or odd parity.
- 3. Read the resultParity calculations, the codeword, or the error position and fix.
How Hamming code works
Hamming code adds parity bits so that any single flipped bit can be found and fixed. For m data bits you need r parity bits, where 2^r ≥ m + r + 1: 3 parity bits for 4 data bits gives Hamming(7,4).
- Parity bits sit at positions that are powers of 2: 1, 2, 4, 8 …; data bits fill the rest.
- Parity bit P1 checks every position whose binary number has bit 1 set (1, 3, 5, 7 …), P2 checks positions with bit 2 set (2, 3, 6, 7 …), and so on.
- Each parity bit is chosen so its group has an even number of 1s (or odd, with odd parity).
To check a codeword, recompute each group. Write a 1 for each failed check; read as a binary number, the syndrome is the position of the wrong bit. 0 means no single-bit error.
Worked example
Encode 1011 with even parity. The layout is P1 P2 D1 P4 D2 D3 D4, with D1–D4 = 1, 0, 1, 1:
- P1 covers positions 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.
The codeword is 0110011. Now suppose bit 5 flips in transit and 0110111 arrives. P1 fails, P2 passes and P4 fails, so the syndrome is 4 + 1 = 5. Flip bit 5 back to get 0110011, and the data 1011 is recovered.
With two flipped bits, plain Hamming code can't tell what happened and may "fix" the wrong bit. Adding one overall parity bit (SECDED) lets memory chips detect double errors as well.
Frequently asked questions
Where is Hamming code used?
In ECC memory, some storage systems and teaching. Modern links often use stronger codes like Reed–Solomon or LDPC.
Even or odd parity: which should I use?
Even is the textbook default. Use whichever your question states; the tool supports both.
Can it correct two errors?
No. Hamming code corrects one error. For two, you need a stronger code.
Is the hamming code calculator free to use?
Yes, the hamming code calculator is free and costs nothing. Your first calculation shows a short form for your name and WhatsApp number one time; once that's done, this tool and every other Uncodemy tool open with no form.