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.
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.
| Parity | Checked positions |
|---|---|
| p1 | 1,3,5,7 |
| p2 | 2,3,6,7 |
| p4 | 4,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
| Concept | Formula or rule |
|---|---|
| Hamming(7,4) | parity bits at positions 1, 2, and 4 |
| Syndrome | binary index of possible one-bit error |
Worked example
Common mistakes
Keep lists comma separated, matrices as rows separated by semicolons, and modular inputs as integers.
Some methods require positive probabilities, valid moduli, independent trials, or small educational input sizes.
Traditional Hamming-code parity positions are powers of two using one-based numbering: 1, 2, and 4.
Certain multi-bit error patterns can evade a basic Hamming(7,4) parity check.
FAQ
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.