# Hamming code for 1111

The Hamming(7,4) code is an error-correction code that adds three parity bits to a 4-bit data word, creating a 7-bit codeword. Here's a step-by-step guide to calculate the Hamming(7,4) code for binary number 1111:

Collect the 4-bit data word that you want to encode. For example, let's say you have a data word: 1111.

Step 2: Determine Parity Bits' Positions

Identify the positions for the three parity bits (P1, P2, P4). These bits will be placed at positions 1, 2, and 4 of the 7-bit codeword. The other positions (3, 5, 6, 7) - (D1, D2, D3, D4) will be filled with the data bits.

In our example: D1 - 1, D2 - 1, D3 - 1, D4 - 1.

Step 3: Calculate Parity Bits

Calculate the values of the parity bits based on the data bits.

Parity Bit P1:

• P1 covers D1, D2, D4
• Calculate the parity over the data bits in these positions (inclusive). Set P1 to 1 if the total number of 1s is odd, otherwise set it to 0.

`P1 = (1 + 1 + 1) % 2 = 1`

Parity Bit P2:

• P2 covers D1, D3, D4
• Calculate the parity over the data bits in these positions (inclusive). Set P2 to 1 if the total number of 1s is odd, otherwise set it to 0.

`P2 = (1 + 1 + 1) % 2 = 1`

Parity Bit P4:

• P4 covers D2, D3, D4
• Calculate the parity over the data bits in these positions (inclusive). Set P4 to 1 if the total number of 1s is odd, otherwise set it to 0.

`P4 = (1 + 1 + 1) % 2 = 1`

Step 4: Construct the Codeword

Insert the calculated parity bits into their respective positions in the codeword.

The codeword becomes: 1111111.
Hamming (7,4) Code Calculator