I'm stuck on the following question that I am trying to use for revision purposes. The question states that the data transmitted is 1001101, however, during transmission the second bit has an error and is received as 1 instead of 0, thus the data is 1101101. I need to use the hamming code to detect this error, however, when doing so, my p1, p2 and p4 values are all equal to 1, giving me 111 and indicating an error with bit 7.

Can anyone please help point me in the right direction? I am new to this so apologies if the error is staring me right in the face.

Thanks in advance for any help.

  • $\begingroup$ I'm not sure that your original codeword belongs to the Hamming code. Perhaps you can state which version you are using? $\endgroup$ May 12, 2021 at 10:41

1 Answer 1


If you are using the Hamming(7,4) code as described in here, then there is already a bit error in $1001101$. Indeed, we have parity bits $p_1 = 1$, $p_2 = 0$ and $p_3 = 1$ and message bits $d_1 = 0$, $d_2 = 1$, $d_3 = 0$ and $d_4 = 1$. Since (for example) $p_2 + d_1 + d_3 + d_4 = 1 \mod 2$, that means that there is a bit error (and it's among $p_2$, $d_1$, $d_3$ and $d_4$).

Now to find which bit was switched, it does not suffice to see the value of $(p_1p_2p_3)_2$, because here it would be $(101)_2 = 5$, since it would indicate an error on the fifth bit, which is $d_2$, but $d_2$ was not in the above list of error candidates.

To find the right (or more exactly the wrong) bit, you need to calculate 3 check values:

  • $c_1 = p_1 + d_1 + d_2 + d_4 \mod 2$
  • $c_2 = p_2 + d_1 + d_3 + d_4 \mod 2$
  • $c_3 = p_3 + d_2 + d_3 + d_4 \mod 2$

And the position of the bit will be given by $(c_1c_2c_3)_2$. In our example, we get $(111)_2 = 7$, so the wrong bit is $d_4$ and the original transmission was $1001100$.

Now there is also a bit error in $1101101$. Can you find it applying this method?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.