Home · Everyday · Bases, Binary & Logic · Hamming Code Calculator

Hamming Code Calculator

How many parity bits does a Hamming code need for your data length? The 2^r ≥ m + r + 1 bound, solved.

Your figures

Example result — edit the figures to make it yours

3

Parity bits needed

Hamming's bound: r parity bits must satisfy 2^r ≥ m + r + 1 — the parity bits have to be able to point at every position (data, parity, and 'no error'). Parity bits sit at positions 1, 2, 4, 8, … and each covers the positions whose index has that bit set. The resulting code corrects any single-bit error.

Total block size7 bits
Code rate0.5714
Parity positions1, 2, 4
With SECDED (extra overall parity)4 parity bits

What this calculator does

How many parity bits does a Hamming code need for your data length? The 2^r ≥ m + r + 1 bound, solved. Where a measure is involved, US and metric units are both accepted — flip the unit toggle and the figures convert with the same definitions the formula uses. Every result on this page is computed from the formula stated below, with no hidden rounding steps.

The formula and method

Smallest r with 2^r ≥ m + r + 1

Hamming codes add parity bits at positions 1, 2, 4, 8, … so any single-bit error can be located and corrected.

The parity-bit count r is the smallest value with 2^r ≥ m + r + 1 for m data bits.

Each parity bit covers the positions whose binary index has that bit set.

Worked example

With the example inputs this page opens with, the result is 3 — parity bits needed. Hamming's bound: r parity bits must satisfy 2^r ≥ m + r + 1 — the parity bits have to be able to point at every position (data, parity, and 'no error'). Parity bits sit at positions 1, 2, 4, 8, … and each covers the positions whose index has that bit set. The resulting code corrects any single-bit error.

Quick reference

Quick reference — the worked example in full
FigureValue
Parity bits needed3
Total block size7 bits
Code rate0.5714
Parity positions1, 2, 4
With SECDED (extra overall parity)4 parity bits

Computed with the same formulas as the calculator above — enter any values there for figures beyond this table.

Common questions

How does the Hamming Code Calculator work?

How many parity bits does a Hamming code need for your data length? The 2^r ≥ m + r + 1 bound, solved. Data bits → Parity bits and block size. The result updates as you type, and the formula and method on this page state the exact definitions used, so you can reproduce the calculation by hand.

What inputs does the Hamming Code Calculator need?

Data bits → Parity bits and block size. Invalid entries — such as a zero denominator, an out-of-range value or a malformed list — produce a plain-language message instead of a misleading number.

Is the Hamming Code Calculator free to use?

Yes. It runs entirely in your browser with no sign-up, and the same calculator is available as an embeddable widget via the Embed button, so it can be placed on another site with its calculation intact.