Hamming (7,4) Code Calculator/Encoder
How This Converter Works
Encodes four data bits as a 7-bit Hamming (7,4) code with even parity.
Formula or rule
Arrange codeword bits as P1,P2,D1,P4,D2,D3,D4; P1 covers positions 1,3,5,7, P2 covers 2,3,6,7, and the third parity bit covers 4,5,6,7. The implementation calls that variable pc (its comment says p3) but places it at position 4.
Example
- Input
- 1011
- Calculation
- P1=0 for data bits 1,0,1; P2=1 for 1,1,1; P4=0 for 0,1,1. Place bits as P1 P2 D1 P4 D2 D3 D4.
- Result
- Transmitted - 0010111