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

  1. Choose encode or decode.
  2. Type the data bits (encode) or the received codeword (decode).
  3. 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:

The calculator gives:

Tips and common mistakes

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

Enter your values to get the result with the formula, substituted values and an explanation of each step.

All engineering calculators