Specific principles can be directly Baidu does not say much, directly write how to solve
First, the premise:
There is only one error in the data bit, which is the basis of the sea-light
Second, XOR or operation
The same is 0, the difference is 1, the XOR symbol is "XOR" or "⊙", for example: 1 xor 1 = 0,1 xor 0 = 1
Three, the basic formula
2^r≥k+r+1
where r is the check digit, K is the information bit information bit is known
Iv. Specific examples
1, Beg (1101) 2 the sea-plaintext
(1) First find out the number and position of the calibration
Number of digits: According to the formula, the minimum number of check digits is 3.
Location: 2^n (n-Times of 2, 1, 2, 4, 8, 16, etc.)
(2) inserting the check digit into the information bit
set: D 0 D 1 D 2 D 3 = 1101,b1b2b3 is a 3 check digit, H1, H2, H3, H4, H5, H6, H7 are all locations, then there are the following tables:
Position |
H1 |
H2 |
H3 |
H4 |
H5 |
H6 |
H7 |
Information bits |
|
|
D0 |
|
D1 |
D2 |
D3 |
Check digit |
B1 |
B2 |
|
B3 |
|
|
|
(3) Determine the check digit
Determine the rule: if you want to verify the first (i), then it is equal to the position of the check sums
For example: To validate H3, H3 = b1+b2
So, we can get the following check-list:
Position |
Number of check digit occupied |
Note |
H1 |
B1 |
1 = 1 |
H2 |
B2 |
2 = 2 |
H3 |
B2,b1 |
3 = 2 + 1 |
H4 |
B3 |
4 = 4 (note H4 position has check bit B3) |
H5 |
B3,b1 |
5 = 4 + 1 |
H6 |
B3,b2 |
6 = 4 + 2 |
H7 |
B3,b2,b1 |
7 = 4 + 2 + 1 |
(4) Determine which locations each check digit verifies
B1:H1, H3, H5, H7
B2:H2, H3, H6, H7
B3:h4, H5, H6, H7
The result is:
B1 = H3 xor H5 xor H7 = 1 xor 1 xor 1 = 1
B2 = H3 xor H6 xor H7 = 1 XOR 0 XOR 1 = 0
B3 = H5 xor H6 xor H7 = 1 XOR 0 XOR 1 = 0
Insert these three check codes to get a code: 1010101
2. Title:
The information bit is 01101110, four test bit C1.C2.C3.C4C1 should make the number of "1" in 1,3,5,7,9,11 bit even, C2 should make the number of "1" in the 2,3,6,7,10,11 bit even; C4 should make "1" in the 4,5,6,7,12 bit C8 should make the number of "1" in the 8,9,10,11,12 bit even
This is a problem Baidu knows, here to explain:
The number of "1" is even for the last difference or the value is 0, for example we have 2 "1" or 4 "1" XOR, definitely get 0
We have set 4 check bits C1, C2, C3, C4, inserted into the information bit will be as follows:
Position |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Information bits |
|
|
0 |
|
1 |
1 |
0 |
|
1 |
1 |
1 |
0 |
Check digit |
C1 |
C2 |
|
C3 |
|
|
|
C4 |
|
|
|
|
So, according to test instructions's information:
1, 3, 5, 7, 9, 11 bits in the number of "1" is an even or the result must be 0:C1 XOR 0 XOR 1 XOR 0 xor 1 XOR 1 = 0, can get C1 = 1
Other values can be obtained in turn
Reference Link: http://zhidao.baidu.com/link?url=3qbO3xiK1bERUaC8cAb9bRZopokZGO4zKSMW9_ hwaaulxmurwlfozxofwmifhfo3zvkd7zyrs46sck25v4nd0_
The principle of computer composition "Hamming check Code" (Soft test)