Hamming Code Calculator
Enter 4 data bits to see the parity bits and full 7-bit codeword generated by the classic Hamming(7,4) error-correcting code.
What Hamming(7,4) Codes Do
Hamming codes add extra ‘parity’ bits to a block of data bits so that a single-bit transmission error can be detected and automatically corrected at the receiving end, without needing to resend the data. Hamming(7,4) is the classic version: 4 data bits become a 7-bit codeword.
The Formula
The 3 parity bits are placed at positions 1, 2, and 4 of the codeword, and each covers a specific subset of the other bit positions using XOR (exclusive-or): P1 = D1 ⊕ D2 ⊕ D4, P2 = D1 ⊕ D3 ⊕ D4, and P4 = D2 ⊕ D3 ⊕ D4. The final 7-bit codeword orders the bits as P1, P2, D1, P4, D2, D3, D4.
If a single bit later flips during transmission, comparing the received parity bits against recalculated ones pinpoints exactly which bit position is wrong. This tool is for computer science and digital communications education.