Hamming Code Calculator
Encode data with Hamming / SECDED parity, or decode, locate and correct an error.
What it does
Hamming code adds parity bits at positions 1, 2, 4, 8… so a single-bit error can be found and corrected. SECDED adds one more bit to also detect double errors.
Where it's used
ECC memory, deep-space and satellite links and learning error-correcting codes.
How to use it
- Choose encode or decode.
- Type the data bits (encode) or the received codeword (decode).
- Choose plain Hamming or SECDED.
The formula explained
- Pᵢ
- parity bit covering every position whose number has bit i set
- Syndrome
- XOR of the positions holding a 1 — non-zero gives the error position
- SECDED
- single-error-correct, double-error-detect
Worked example
Encoding 8 data bits with SECDED.
Inputs:
- Mode: Encode data bits
- Bits: 11010110
- Code type: Extended Hamming (SECDED, overall parity last)
The calculator gives:
- Codeword: 0010101001101
- Code: (13,8)
- Parity bits: 5
Tips and common mistakes
- Positions are numbered from 1, not 0.
- Plain Hamming can mis-correct a double error; SECDED flags it instead.
- More data bits need only a few extra parity bits — efficiency improves with size.
Questions people ask
How many parity bits do I need?
The smallest r with 2^r ≥ data bits + r + 1. 4 data bits need 3, giving a (7,4) code; 8 data bits need 4, giving (12,8). SECDED adds one more overall parity bit, so (13,8).
How does the receiver find the bad bit?
It recalculates every parity bit. The ones that fail, read together as a binary number (the syndrome), give the position of the flipped bit. A syndrome of 0 means no single-bit error.
Where is Hamming code used?
ECC memory in servers uses a SECDED code with 8 check bits for every 64 data bits, which corrects any single-bit error and flags double ones. Flash memory and spacecraft use similar codes.
Related Digital Logic calculators
- Binary Calculator
- Number System Converter
- Logic Gate Calculator
- Two's Complement Calculator
- Parity Bit Calculator
- Truth Table Generator
- Karnaugh Map Solver
- Gray Code Converter
- Bitwise Calculator
- Bit Shift Calculator
Enter your values to get the result with the formula, substituted values and an explanation of each step.