What is a number system? Rules used to represent numeric values, such as decimal and binary.
Machine count
Represents a number in binary format. The highest digit is the sign bit. 1 indicates a negative number, and 0 indicates a positive number.
For example: 1 ----> 00000001;-1 ----> 1000 0001
True Value
We can see from the above that the number of machines is a form of computer used to represent the number, but the maximum bit is a symbol. In this case, 1000 0001 represents 1 rather than 129. In this way, we call the value of true meaning represented by a machine number a true value.
Source code, reverse code, and supplementary code
In general, the back-Code complement of the original code is a method used by computers to store numbers.
Original code
Rule: Symbol bit + absolute value of True Value
For example, [+ 1] source code = 0000 0001;
[-1] source code = 1000 0001;
Reverse code
Rule: Positive and Negative Numbers are themselves
The Negative Inverse code is the inverse of the original code, but the symbol bit remains unchanged.
For example, [+ 1] source code = [+ 1] Anti-code = 0000 0001;
[-1] source code = 1000 0001 = [-1] Reverse code = 1111 1110;
Complement
Rule: positive value complement itself
Add 1 based on the reverse code of the original code.
For example, [+ 1] source code = [+ 1] complement;
[-1] source code = 1000 0001 = [-1] Anti-code = 1111 1110 1111 = [-1] Complement = 1111;
Why are three representation methods available?
Through the above three methods, we can get positive number 1 which is consistent in various cases: [+ 1] original \ reverse \ complement code = 0000 00001;
The reverse code is not consistent.
Inside the computer, to simplify the operation. The symbol bit is also input into the operation, so that the computer does not need to analyze the role of the symbol bit. But we found that
[+ 1] source code = 0000 0001 + [-1] source code = 1000 0001 0000 = 00001 = 1; instead of 0, an error occurs. How can this problem be solved?
To solve this problem, the reverse code is displayed.
[+ 1] source code + [-1] source code = 1000 0001 0000 = [+ 1] Reverse code = 0001 1111 1110 + [-1] Reverse code = 0000 0000 (reverse code) = 0000 0000 (original code) =-0;
In this way, the calculation between original codes is solved, but the problem becomes-0 = 1000 0000 (original code); + 0 = 0000 0000 (original code); this is different from the computer. Is meaningless.
[+ 1] source code + [-1] source code = 1000 0001 0000 = [+ 1] completion code = 0001 1111 1111 + [-1] completion code = 0000 0000 (Completion code) = [0000 0000] (original code)
In this way, [0000 0000] (original Code) is used to indicate 0, so no problem will occur.
In general, in integers, the original code is the same as the complement and anti-code. If the negative number is the same as the symbol bit, you will get the opposite result. The complement Code adds 1 to the anticode. the appearance of the original code complement anticode is to make it easier and more convenient for the computer in the computation process.