HAM Error Control Code

Hamming Code Calculator

Encode and decode Hamming codes, calculate parity bits and syndrome values, detect a single-bit error, automatically correct the erroneous bit and recover the original binary data.

Encode Decode Error Detection Error Correction Even / Odd Parity Syndrome
Hamming Code Calculator Encode + Decode + Correct
Encode generates a Hamming code. Decode checks a received codeword.
The same parity convention must be used when encoding and decoding.
Enter original binary data bits to encode.
Hamming Code Result
Input Data
Encoded / Received
Parity Bits
Parity Positions
Syndrome
Error Position
Corrected Code
Recovered Data
Hamming Analysis
Parity Calculation Table
Parity Bit Position Checked Positions Ones Count Parity Value
Enter data and calculate to view parity analysis.

What Is Hamming Code?

Hamming code is a family of error-control codes that adds strategically positioned parity bits to binary data. The additional parity information allows a receiver to identify the position of a single erroneous bit and correct it.

Parity bits are placed at positions that are powers of two: 1, 2, 4, 8, 16 and so on. All remaining positions contain the original data bits.

What This Hamming Code Calculator Does

Hamming Code Encoder

Enter original data bits and the calculator automatically determines how many parity bits are required and generates the complete Hamming codeword.

Hamming Code Decoder

Enter a received Hamming codeword to recover the original data bits after parity analysis.

Error Detector

The calculated syndrome identifies whether a single-bit error exists and indicates its position.

Error Corrector

When a valid single-bit error position is detected, the calculator flips that bit and returns the corrected Hamming codeword.

How Many Hamming Parity Bits Are Required?

For m data bits and r parity bits, the number of parity bits must satisfy:

2^r >= m + r + 1
Data Bits Minimum Parity Bits Total Hamming Bits
1 2 3
2 3 5
3 3 6
4 3 7
5 to 11 4 9 to 15
12 to 26 5 17 to 31

Hamming Parity Bit Positions

Parity bits occupy positions that are powers of two. Data bits fill all other positions.

Position: 1 2 3 4 5 6 7

Type: P1 P2 D1 P4 D2 D3 D4

This arrangement allows each bit position to be uniquely represented by the combination of parity checks that include it.

Hamming Code Encoding Example

For four data bits, three parity bits are required because:

m = 4
r = 3

2^3 = 8
m + r + 1 = 8

Therefore:
7-bit Hamming codeword

The calculator places the data into non-power-of-two positions and calculates parity bits according to the selected even or odd parity rule.

What Is a Hamming Syndrome?

The syndrome is produced by recalculating the parity checks of a received Hamming codeword. Each failed parity check contributes its parity position to the syndrome.

Syndrome = 0
No single-bit error detected

Syndrome = 5
Error detected at bit position 5

The syndrome therefore acts as the binary address of the erroneous bit in a standard single-error-correcting Hamming code.

How Hamming Code Detects an Error

Each parity bit checks a different group of positions. If a transmitted bit changes, some parity groups fail while others remain valid.

Combining the failed parity positions produces the syndrome, which identifies the bit that should be corrected.

How Hamming Code Corrects a Single-Bit Error

Received code:
1010101

Suppose syndrome:
5

Detected error:
Position 5

Correction:
Flip bit 5

0 becomes 1
or
1 becomes 0

After correction, data bits can be extracted from every non-parity position.

Even vs Odd Hamming Parity

Parity Type Rule Goal
Even Parity Choose parity bit so checked group has an even number of ones Total ones count becomes even
Odd Parity Choose parity bit so checked group has an odd number of ones Total ones count becomes odd

Encoder and decoder must use the same parity convention or the syndrome result will not be meaningful.

Standard Hamming Code vs SECDED

This calculator implements the standard Hamming single-error-correcting structure. Standard Hamming code can locate and correct one erroneous bit under the single-error assumption.

SECDED systems add an additional overall parity bit so they can provide Single Error Correction and Double Error Detection. That extended overall parity bit is not automatically added by this calculator.

Hamming Code Applications

Computer Memory

Error-correcting memory systems use related error-control techniques to detect and correct corrupted bits.

Digital Communications

Hamming codes demonstrate how redundant bits can improve reliability when data travels through noisy channels.

Computer Architecture

The syndrome concept is useful for learning hardware error-detection and correction logic.

Coding Theory

Hamming codes are a fundamental introduction to linear block codes, code distance and syndrome decoding.

Important Hamming Code Notes

Important: this calculator implements standard Hamming single-error correction.

Parity bit positions are numbered from the rightmost bit as position 1. This is important when reading the reported error position.

A syndrome of zero means all Hamming parity checks passed.

A nonzero syndrome identifies the position to flip under the assumption that no more than one bit is incorrect.

Standard Hamming code alone should not be assumed to reliably distinguish every possible multi-bit error pattern.

For guaranteed single-error correction plus double-error detection, an extended Hamming SECDED scheme with an additional overall parity bit is required.

Related BinaryCon Tools

Hamming Code Calculator FAQs

What does a Hamming Code Calculator do?
It can generate Hamming codewords, decode received codewords, calculate the syndrome, identify a single-bit error and correct that bit.
Where are Hamming parity bits placed?
Parity bits are placed at positions that are powers of two, such as 1, 2, 4, 8 and 16.
How many parity bits are required?
For m data bits, choose the smallest r that satisfies 2 raised to r being at least m plus r plus 1.
What is a Hamming syndrome?
The syndrome combines failed parity checks and identifies the position of a single erroneous bit.
What does syndrome 0 mean?
It means all parity checks passed and no single-bit error was detected.
Can Hamming code correct an error?
Standard Hamming code can correct one erroneous bit when the received word contains no more than one error.
How is an error corrected?
The syndrome identifies the erroneous bit position and the decoder flips that bit from zero to one or from one to zero.
Does the calculator support even parity?
Yes. Even parity is available and is the default option.
Does it support odd parity?
Yes. Select Odd Parity before encoding or decoding.
Can Hamming code detect two errors?
Standard Hamming parity provides a syndrome intended for single-error correction. Extended SECDED Hamming code adds an overall parity bit to provide reliable double-error detection.
How are original data bits recovered?
After correction, the decoder removes positions that are powers of two and combines the remaining data-bit positions.
How are bit positions numbered in this calculator?
Position 1 is the rightmost bit of the displayed Hamming codeword, matching the conventional parity-position numbering used in the calculation.
Scroll to Top