To better understand some data operations, you need to understand the binary representation of the data:
(1) original code representation
The original code representation is a simple representation of the number of machines. Its sign bit uses 0 to represent the positive number, and uses: To represent the negative number. The value is generally expressed in binary format. If one number is set to x, the original code can be recorded as [x.
For example, X1 = + 1010110
X2 = 1 1001010
The original code is recorded:
[X1] original = [+ 1010110] original = 01010110
[X2] original = [-1001010] original = 11001010
The range of the original number is related to the binary number. When an 8-bit binary is used to represent the decimal original code, the range is as follows:
The maximum value is 0.1111111, and its true value is about (0.99) 10.
The minimum value is 1.1111111, and its true value is about (1, 0.99) 10.
When an integer original code is expressed in 8-bit binary, the range is as follows:
The maximum value is 01111111, and its true value is (127) 10.
The minimum value is 11111111, and its true value is (-127) 10.
In the original code representation method, there are two forms for 0:
[+ 0] original = 00000000
[-0] original = 10000000
(2) Complement Representation
The number of machines can be obtained by the original code. If the number of machines is positive, the complement code of the number of machines is the same as the original code; (from: Graph code network) if the number of machines is negative, then, the complement code of the number of machines is obtained based on the reverse code of the original code (except the symbol bit) and the value of 1 in the undigit. If there is a number of X, the complement representation of X is recorded as [X.
For example, [X1] = + 1010110
[X2] = 1 1001010
[X1] original = 01010110
[X1] Supplement = 01010110
That is, [X1] original = [X1] Supplement = 01010110
[X2] original = 11001010
[X2] fill = 10110101 + 1 = 10110110
The value range is related to the number of binary digits. When 8-bit binary representation is used, the decimal complement range is as follows:
The maximum value is 0.1111111, and its true value is (0.99) 10.
The minimum value is 1.0000000, and its true value is (1) 10.
The value range of the integer complement when the 8-bit binary representation is used:
The maximum value is 01111111, and its true value is (127) 10.
The minimum value is 10000000, and its true value is (128) 10.
In the complement representation method, 0 has only one representation:
[+ 0] Supplement = 00000000
[+ 0] fill = 11111111 + 1 = 00000000 (due to the limitation of the device font length, the final carry loss)
Therefore, [+ 0] fill = [+ 0] fill = 00000000
(3) reverse code representation
The back code of the number of machines can be obtained from the original code. If the number of machines is positive, the inverse code of the number of machines is the same as the original code. If the number of machines is negative, the inverse code of the number of machines is the original code of the machine (except the symbol bit) what you get. If there is a number of X, the reverse code of X is recorded as [X.
Example: X1 = + 1010110
X2 = 1 1001010
[X1] original = 01010110
[X1] Reverse = [X1] original = 01010110
[X2] original = 11001010
[X2] reversed = 10110101
The anticode is usually used as the intermediate form of the complement process. That is, if 1 is added to the unbitwise of a negative number, the complement code of this negative number is obtained.
Example 1. If [X] original = 10011010 is known, perform [X] complementing.
The analysis is as follows:
The principle of [X] original [X] population is: if the number of machines is positive, [X] original = [X] fill; if the number of machines is negative, the complement code of the number of machines can reverse all its original codes (except the symbol bit), and then get it by adding 1 to the undigit. Given that the number of machines is negative, [X] fill = [X] the original 10 1, that is
[X] original = 10011010
[X] anti = 11100101
10) 1
[X] Supplement = 11100110
Example 2. If [X] Complement = 11100110 is known, obtain the original [X.
The analysis is as follows:
If the number of machines is positive, [X] original = [X] is supplemented.
If the number of machines is negative, [X] original = [X] Complement] is provided.
Given as a negative number, there are:
[X] Supplement = 11100110
[[X] Complement] Reverse = 10011001
10) 1
[[X] fill = 10011010 = [X] original