[<< wikibooks] A-level Computing/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Fundamentals of Data Representation/Hamming code
Building on what you have learnt about parity bits we are now going to see a system that not only allows you to detect if the data you have been sent is incorrect, but it will allow you to correct the error.  The way hamming code does this is to use multiple check digits in the same piece of sent data.


== Checking if correct ==
Number the column headings
Highlight the column headings that are powers of 2 (1,2,4,8), these are the parity bits
Insert your data and highlight the parity bits
Work your way through the parity bits
2^0 = 1 : check 1, skip 1, check 1, skip 1 ... write down whether it's odd or even parity
2^1 = 2 : check 2, skip 2, check 2, skip 2 ... write down whether it's odd or even parity
2^2 = 4 : check 4, skip 4, check 4, skip 4 ... write down whether it's odd or even parity
etc..


=== Detecting and correcting errors ===
Number the column headings
Highlight the column headings that are powers of 2 (1,2,4,8), these are the parity bits
Insert your data and highlight the parity bits
Work your way through the parity bits
2^0 = 1 : check 1, skip 1, check 1, skip 1 ... write down whether it's odd or even parity
2^1 = 2 : check 2, skip 2, check 2, skip 2 ... write down whether it's odd or even parity
2^2 = 4 : check 4, skip 4, check 4, skip 4 ... write down whether it's odd or even parity
etc..
If there is a disparity between rows, highlight all the error data and find where it overlaps


== Applying hamming code ==
Number the column headings
Highlight the column headings that are powers of 2 (1,2,4,8), these are the parity bits
Insert your data into the bits that aren't parity bits
Work your way through the parity bits
looking at 2^0 : check 1, skip 1, check 1, skip 1 ... write the parity bit in column 1 to make the bits the desired parity
looking at 2^1 : check 2, skip 2, check 2, skip 2 ... write the parity bit in column 2 to make the bits the desired parity
looking at 2^2 : check 4, skip 4, check 4, skip 4 ... write the parity bit in column 4 to make the bits the desired parity
...