I. Conceptual understanding 1. Number of machines
A number in a computer in the form of a binary tab, called the number of machines;
The number of machines is signed, the highest bit deposit symbol (0 positive, 1 negative);
00000011 and 10000011 are the number of machines;
2. Truth
The true value corresponding to the number of machines with symbols is called the truth of the number of machines;
The truth value of 00000011 is +1;
10000011 of the truth is-1;
3. Original code
The original code is the absolute value of the symbolic bit plus the truth;
[+1]=[0000 0001] original;
[ -1]=[1000 0001] original;
4. Anti-code
The inverse code of a positive number is its own;
The inverse code of negative number is on the basis of its original code, the sign bit is unchanged, and the remaining bits are reversed;
[+1]=[0000 0001] original = [0000 0001] reversed;
[-1]=[1000 0001] original = [1111 1110] reversed;
5. Complement
The complement of a positive number is its own;
The complement of negative numbers is on the basis of the inverse code +1;
[+1]=[0000 0001] original = [0000 0001] Anti = [0000 0001] complement;
[-1]=[1000 0001] original = [1111 1110] anti = [1111 1111] complement;
Second, why use the original code, anti-code, complement
1. Because the computer only knows the addition, for subtraction is added a negative number;
2. In order to be more simple in computing design, the symbol bit is also involved in the operation;
3. Using the original code to do the operation
1-1=1+ (-1) =[0000 0001] Original + [1000 0001] original = [1000 0010] Original =–2
It is concluded that using the original code to calculate the subtraction, let the sign bit participate in the calculation, the result is not correct
4. Use the inverse code to do the operation
1-1=1+ (-1) =[0000 0001] anti-+[1111 1110] anti-=[1111 1111] anti = [1000 0000] Original =–0
The conclusion is that the inverse code calculation and subtraction are used to solve the incorrect truth part, the only problem is that the special value of "0", 0 with the symbol is meaningless.
[0000 0000] anti = [1000 0000] Anti = 0, and 0 of the anti-code has two representations
5. Use the complement to do the arithmetic
1-1=1+ (-1) =[0000 0001] complement +[1111 1111] complement = [0000 0000] Fill =[0000 0000] Original = 0
This is denoted by 0 in [0000 0000] and is represented by [1000 0000]-128
(-1) + (-127) =[1000 0001] Original +[1111 1111] original =[1111 1111] fill +[1000 0001] fill =[1000 0000] Complement
is actually using the previous-0 complement to represent-128, so 128 does not have the original code and the inverse code
Conclusion: The use of complement calculation, not only fixed 0 of the symbol has two coding problems, but also can represent a minimum number
Three, the original code, anti-code, complement the scope of the expression
Original code:
The first bit is the sign bit, and the range of all 8-bit binary values is:
[1111 1111,0111 1111] i.e. [-127,127]
Anti-code:
Anti-code is obtained through the original code, so the range and the same as the original code, is also [-127,127]
Complement:
The complement is a minimum number more than the inverse code, that is, the range is [-128,127]
Basic computer (1)-Original code, inverse code, complement