Hamming Code Calculator

Encode 4 data bits into a Hamming(7,4) code and optionally check a received word. This educational calculator shows the formula, result, and step-by-step interpretation.

Computer ScienceCoding Theory

Calculator

What this calculator teaches

Hamming codes add parity bits so a one-bit error can be detected and corrected.

Use the result as a learning aid. For classwork, still show the formula and intermediate reasoning so the final answer is not just a black-box number.

Understanding Hamming(7,4)

Hamming(7,4) turns four data bits into a seven-bit codeword by adding three parity bits. Using one-based positions, parity bits occupy positions 1, 2, and 4, while data bits occupy positions 3, 5, 6, and 7. Each parity bit checks a different overlapping set of positions.

With even parity, p1 checks positions 1,3,5,7; p2 checks 2,3,6,7; and p4 checks 4,5,6,7. At the receiver, the same parity checks form a three-bit syndrome. Interpreted as a binary index, a nonzero syndrome points to the position of a possible single-bit error.

ParityChecked positions
p11,3,5,7
p22,3,6,7
p44,5,6,7

Standard Hamming(7,4) has minimum distance 3, so it can correct one bit error in a codeword. It does not reliably correct arbitrary two-bit errors. Extended Hamming codes add an overall parity bit to improve double-error detection.

Formula & Symbols

ConceptFormula or rule
Hamming(7,4)parity bits at positions 1, 2, and 4
Syndromebinary index of possible one-bit error

Worked example

Example: The calculator places data bits in positions 3,5,6,7 and computes parity bits.
Example 2: Data 0000 encodes as 0000000 under even parity.
Example 3: Data 1011 places data in positions 3,5,6,7 and computes parity bits so each check set has even parity.
Example 4: If the syndrome equals 5, the parity checks indicate a possible error at bit position 5.
Example 5: A syndrome of 0 means the three Hamming parity checks pass; it does not prove that every multi-bit error is absent.

Common mistakes

⚠️
Using the wrong input format

Keep lists comma separated, matrices as rows separated by semicolons, and modular inputs as integers.

⚠️
Ignoring assumptions

Some methods require positive probabilities, valid moduli, independent trials, or small educational input sizes.

⚠️
Numbering positions from zero

Traditional Hamming-code parity positions are powers of two using one-based numbering: 1, 2, and 4.

⚠️
Assuming syndrome 0 proves perfect transmission

Certain multi-bit error patterns can evade a basic Hamming(7,4) parity check.

FAQ

Can I use decimals?
Most numerical calculators allow decimals, but modular arithmetic and coding-theory tools usually require integers or binary strings.
Is this for homework checking?
Yes. The page is designed to show both the answer and the reasoning pattern.
Why does the result sometimes say approximate?
Some probability, floating-point, and numerical methods naturally produce approximations.
Why are parity bits at positions 1, 2, and 4?
Those powers-of-two positions let each data position have a unique binary participation pattern across the parity checks.
What does syndrome 3 mean?
Under the standard indexing convention, it points to a possible one-bit error at position 3.
Can Hamming(7,4) correct two errors?
No. Its standard guarantee is single-error correction. Two errors can produce a misleading syndrome.
How many data bits are in Hamming(7,4)?
Four data bits are combined with three parity bits to form seven transmitted bits.

How to Check the Codeword

Once a seven-bit word is formed, verify each even-parity group independently. Count the 1s in positions 1,3,5,7; then 2,3,6,7; then 4,5,6,7. Every count should be even for a valid even-parity Hamming(7,4) codeword. This gives a transparent manual check of the three parity equations.

For a received word, the three failed/pass results form the syndrome. The p1 check is the 1s place, p2 the 2s place, and p4 the 4s place. For example, failed p1 and p4 but passed p2 gives syndrome 1+4=5, pointing to position 5 under the single-error assumption. After flipping the indicated bit, recompute all three checks; a corrected single-bit error should leave syndrome 0.

Related calculators

These links will work after the calculators are registered in the final Math layout update.

Formula Explorer connections

Interpretation: This relationship models the evolution, stability, transform or response of an engineering and differential-equation system. Assumption: Initial conditions, boundary conditions, units, model order and numerical step size must match the physical system; approximations require convergence checks.

Initial Value Problem Calculator →Inverse Laplace Transform Calculator →Lagrange Multiplier Calculator →Math Formula Explorer →