The computer check code data representing && (easy to understand)

First, data representation

Number of machines: various numerical representations in the computer. Which is characterized by a binary counter, the number of symbols 0 and 1 with the identification, the decimal point is implied, it does not occupy the position represented. With a number of machines are divided into symbols and unsigned. Unsigned called positive.

For example, the decimal number of +3, the computer word length is 8 bits, is converted into binary  0000 0011 . If it is -3, it is 10,000,011

Truth values: true value of the actual output values written corresponding to the number of machines.

Because the first one is the sign bit, so the number of machines in the form of value is not equal to the true value. The above example has the symbol number 10000011 , which represents the most significant bit negative, its real value is -3, instead of 131 as a value ( 10000011 converted to decimal equal to 131). Therefore, for the sake of distinction, the real value of the number corresponding to the sign with a machine called a true value of the machine .

Code system: For ease of calculation, the number of machines may be used with different symbols encoding the original code, anti-complement code, and the like, which is called encoding code system.

1. The original code

Original code is the sign bit plus the absolute value of the true value.

Original code representation, the most significant bit is the sign bit, the positive identification number 0, 1 denotes a negative number, the absolute value of the remaining n-1 bits represent the value. In particular, 0 represents the original code has two forms: [+ 0] = 00000000, [- 0] = 10000000.

2. anti-code

In the anti-code representation, the most significant bit is the sign bit, the positive identification number 0, number 1 indicates a negative, positive anti-code the same code as the original, the original code is the negative absolute value bitwise. In particular, the inverted 0 indicates there are two: [+ 0] = 00000000 [-0] = 11111111.

Generally speaking,

Inverted negative which is based on the original code, change the sign bit, each bit is inverted to rest.

[L] = [0000 0001] Original = [0000 0001] trans

[-1] = [1000 0001] Original = [1111 1110] trans

3. Complement

In complement notation, the most significant bit is the sign bit, the positive identification number 0, number 1 indicates a negative, a positive number of the same complement of the original code and its inverted, negative complement last bit equal to 1 plus the radix particularly 0 complement: [+ 0] = 00000000 [-0] = 00000000.

Generally speaking,

[L] = [0000 0001] Original = [0000 0001] trans = [0000 0001] Complement

[-1] = [1000 0001] Original = [1111 1110] trans = [1111 1111] Complement

 

Second, check code

A computer system to ensure that the correct data during transmission, one is to improve the reliability of the hardware circuit, the second is to improve the checking capability of the code, including error checking and correction. Typically detected by checksum.

1. parity

Parity code (Parity Codes) is a simple and effective method of checking. This coding method in an increase in the number of parity bits to enable encoding is odd (odd parity) or even (even parity), so that the code distance becomes 2.

Often a special set of parity bits , which makes use this code to the number of "1" is odd or even. If using odd parity, when the receiver receives the set of codes, the number of parity "1" if an odd number, to determine the correctness of the transmission code.

Odd: + parity bit code stream total odd number.

Odd parity is added to the end by way of a 1 or 0 so that the number is odd. Whether the number of 1 by an odd number when determining whether an error check. Even parity empathy.

Parity: + parity code stream even number of a total of 1

For example odd parity:

As will be encoded as 11001100 11001100 1 (1 is added as the last one, that the number of 1 is an odd number 5)

When the number of errors is odd, odd number of 1 will result in a change, an error can be detected, but is an even number, an odd number of constant, so undetectable, have even parity.

When there are three (odd number of) error bits, then it is assumed that after three time becomes the number 1 110010111 6 becomes to be judged wrong. And two (even number of) error bits, then it is assumed that after the two at this time becomes the number 110011111 1 7 still is odd, no error is detected the

The basic principle here is that experience: an odd plus even-odd still, it becomes odd plus even.

 

2. Hamming code

Utilizing error detection parity for error correction check method. K parity bits are inserted at a specific location between the data bits from the error correction achieved by expanding the code.

Reprinted: https: //www.jianshu.com/p/f8a0477ca313

 

3. Cyclic Redundancy Check (CRC)

Is the use of the principle of the division and the remainder to make the error detection.

CRC calculation is a method of checking the accuracy of digital transmission communication link (agreed to establish the relationship between the data and check bits by some mathematical operations  [1]  ). The sending computer using a formula to calculate a value of the information contained in the data to be transmitted, and this value is appended after the data transfer, the recipient computer is the same data the same calculation, the same results should be obtained. If these two CRC results are inconsistent, then transmission error has occurred, the recipient computer may request the sending computer to resend the data.

Compared to other verification methods have certain advantages when using a CRC check on the computer network communication.

Guess you like

Origin www.cnblogs.com/lvqiang/p/11607847.html
Recommended