I use [8;4] Hamming code to code, decode and correct the errors in 4-bit messages. I do it as follows: (I'll use 0-7 indexation, not 1-8)
1) Let source message is 1100. Then I add 4 control zero bits to it (0,1,3,7): So the message 0 0 1 0 1 0 0 0. Then I calculate the control bits by checking how many 1s in corresponding bits and then set 0 to a control bit if its number is even or 1 if it's odd. Last bit is just a XOR (or amount of 1s) of the all previous bits. In this example the number of 1s in message is even so last bit is set to 0. So the encoded message now is: 0 1 1 1 1 0 0 0.
2) I receive the message. Firstly I set all control bits (0, 1, 3, 7) to zero.Then I recalculate them using the same algorithm as in the 1st part. Then I compare all 4 control bits in original received message and in recalculated message. If I see the difference between corresponding control bits, I add the index of this bit to a variable which will have the erroneous bit index in the end of comparison. After that I inverse the erroneous bit on this index and then remove 4 control bits and get the decoded message.
In case of the first example, there're no erroneous bits and everything is ok, algorithm didn't find the error, and I got 1100 as a decoded message.
But there's a problem: let message be 1100. When I encode it, it's 01111000. We received the message with 1 error in 4th bit: 0 1 1 1 0 0 0 0. When I decode it, I as usual firstly zero out all 4 control bits: 0 0 1 0 0 0 0 0. I recalculate them using the same algorithm: 1 1 1 0 0 0 0 1. The last bit is set to 1. If we try to calculate the erroneous bit index we will certainly fail, because last (7) bit is set to 1. If I add this index to the variable which keep the erroneous bit index, it will certainly be out of range. Thus we can't correct the error.
So the question is - how exactly this bit should be correctly used to correct/detect the error? I've read very big amount of papers and websites about extended codes, but nobody says exactly how this 8th bit should be correctly used.I suppose it should be used somehow differently..?