Richard W. Hamming was a theorist a Bell Telephone laboratories in the 1940s.
Back then, one of the best computers was the Bell Model V. It occupied about the
space of a small football field, and would have taken years to do calculations
that would take only nanoseconds on the simplest pocket calculator today. It was
a type of relay computer, that took as input punched cards, and a whole crew of
operators. Inevitably, **errors were introduced into the input.** The
computer had two methods of error handling . When operators were present, it
would halt and lights would flash so that the operators could track down the
error. The other method, used on weekends, was to simply skip to the next
calculation. Hamming, who had the use of the computer on weekends, was really
frustrated by constantly having to restart his computations, so he devised the
first error-correcting codes.

The above was copied from http://www.cs.mcgill.ca/~smroso/hamming.html#ste

__Example,__

Use an **even parity** **Hamming code** to write the following word in memory:

**10101101**

__Solution:__

1. There are 8 bits for the word **10101101**.

2. Rewrite 8 into 2^{3} and extract the power ( exponent).
The power is 3 and there will be 4 parity bits.

The number of parity bits = the exponent + 1.

3. There will be 8 + 4 = 12 bits for Hamming code.

4. Fill in the information in 12 bits now.

First decide the locations of parity bits. i.e. 2^{0}=**1**,
2^{1}=**2,** 2^{2}=**4,**
and 2^{3}=**8**.

1 |
0 |
1 |
0 |
1 |
1 |
0 |
1 |
Code | ||||

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | digit |

p |
p |
p |
p |
parity |

Fill in
original word: **10101101**.

Fill in 0 in the parity bits.

0 | 0 | 1 |
0 | 0 |
1 |
0 |
0 | 1 |
1 |
0 |
1 |
Code |

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | digit |

p |
p |
p |
p |
parity |

Check:

1. Add every other bits starting bit 1. i.e. Add bit 1, bit 3, bit
5, bit 7, bit 9, and bit 11 together.

0 + 1 + 0 + 0 + 1 + 0 = 2 even.

2. Add every other two bits starting bit 2. i.e. Add **bits
2 and 3**, skip bits 4 and 5, **plus bits 6 and 7**, skip bits 8 and
9, **plus bits 10 and 11**

0 + 1 + 1 + 0 + 1 + 0 = 3 odd. So, change bit 2 to **1**.

0 | 1 |
1 |
0 | 0 |
1 |
0 |
0 | 1 |
1 |
0 |
1 |
Code |

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | digit |

p |
p |
p |
p |
parity |

3. Add every other four bits starting bit 4. i.e. **Add bits 4, 5, 6,
7 **and skip bits 8, 9, 10, 11, **plus bits12**,...and so on.

0 + 0 + 1 + 0 + 1 = 2 even.

4. Add every other eight bits starting bit 8.

0 + 1 + 1 + 0 + 1 = 3 odd. So, change bit 8 to **1**.

0 | 1 |
1 |
0 | 0 |
1 |
0 |
1 |
1 |
1 |
0 |
1 |
Code |

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | digit |

p |
p |
p |
p |
parity |