Richard Hamming in 1950 produced an innovative way to improvethe string parity errorchecking process to ensure data isaccurately and reliably transmitted. Parity is often referred to asODD or EVEN, by adding up the bit values in a string. If EVENparity is used, the string 10110101, which has 5 bits, is appendedwith the value 1 to make the total number of bits even. If ODDparity is used, the same string would be appended with a 0, tomaintain an odd total for all the bits, resulting in 101101010 asthe transmitted string. Hamming's work produced not only a way tocheck if there is an error, but where the error is in the string.For a bit string of length 8, which is 2^3, 4 bits can be added tocreate Hamming parity string. For a string of 2^N bits, theleftmost bit is considered position 1 and the rightmost bit isposition 2^N. The parity bits will be placed at each position thatis a power of 2 (i.e., at positions 1, 2, 4, 8, 16, …), with theactual data bits starting in position 3, then 5, 6, 7, 9, 10, ...and so on. For the string 10110101, which can be represented by thehex string B5, the Hammond parity string would start out as: 1 2 34 5 6 7 8 9 10 11 12 _ _ 1 _ 0 1 1 _ 0 1 0 1 To find the bit valuein position 1, add up all of the odd position bits, with any blankcounting as a zero. This would be 0+1+0+1+0+0, for a total of 2,which is even, therefore no bit needs to be added, making the valueof position 1 zero. 1 2 3 4 5 6 7 8 9 10 11 12 0 _ 1 _ 0 1 1 _ 0 10 1 To find the bit value in position 2, start at position 2 anduse two bits, then skip 2, use 2, skip 2, and so on resulting insumming the values in positions 2, 3, 6, 7, 10, and 11, for a sumof 0+1+1+1+1+0, or 4, again even parity resulting in zero forposition 2. 1 2 3 4 5 6 7 8 9 10 11 12 0 0 1 _ 0 1 1 _ 0 1 0 1 Tofind the bit value in position 4, start at position 4 and use 4bits, then skip 4, use 4, skip 4, and so on resulting in summingthe values in positions 4,5,6,7, and 12, for a sum of 0+0+1+1+1, or3, needing a 1 in position 4 to make it even parity. The value ofthe 8 bit would use the same pattern as the others: use 8, skip 8,and so on, summing the bits in positions 9, 10, 11, and 12, for atotal of 2, even parity and zero for position 8. In general, for aparity bit at position P, where P is a power of 2, the generalpattern
continues in the same manner: start at position P then use Pvalues, skip P values, and so on… Here is the final transmittedstring. The added parity bits in positions 1, 2, 4, and 8 are:0010. 1 2 3 4 5 6 7 8 9 10 11 12 0 0 1 1 0 1 1 0 0 1 0 1 For oddparity, the example above would result in a bit string of 1101. 1 23 4 5 6 7 8 9 10 11 12 1 1 1 0 0 1 1 1 0 1 0 1 Therefore, write aprogram given a hex string and parity type output the resultingHamming parity string. Input a hex string from the keyboardfollowed by the word EVEN or ODD to indicate the parity separatedby a space. Assume the hex string will produce no more than 128bits and all input will be valid. Output to the screen theresulting Hamming parity value for the given hex string. Finally,ask the user if he/she wishes to run the program again (checkcase). Refer to the sample output below. Sample Run: Enter a hexstring and parity type: ABC ODD Hamming ODD parity string of ABC:11101 Run again (Y/N): y Enter a hex string and parity type: F EVENHamming EVEN parity string of F: 111 Run again (Y/N): N
Richard Hamming in 1950 produced an innovative way to improve the string parity errorchecking process to ensure data is
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am