1. Original code
The highest bit is used as the sign bit (0 for positive, 1 for negative), and the remainder represents the absolute value of the value itself (in binary notation).
For the sake of simplicity, we use 1 bytes to represent an integer.
+7 The original code is: 00000111
-7 of the original code is: 10000111
2. Anti-code
If a number is positive, then its inverse code is the same as the original code; If a number is negative, the sign bit is 1, and the rest of you are reverse the original code.
For the sake of simplicity, we use 1 bytes to represent an integer:
+7 The anti-code is: 00000111
-7 of the anti-code is: 11111000
3. Complement
Complement: If a number is positive, then its original code, anti-code, and the same complement; If a number is negative, the sign bit is 1, and the rest of you are reversed on the original code, then the whole number is added 1. For the sake of simplicity, we use 1 bytes to represent an integer:
The +7 complement is: 00000111
-7 of the complement is: 11111001
If you know the complement of a negative number, convert it to decimal, step:
1, first of all to take the opposite;
2, convert it to a decimal number;
3, plus minus, minus 1.
For example:
11111010, the highest bit is 1, is negative, first for you to take the reverse 00000101, converted to a decimal number of 5, plus minus 5, and then reduced by 1-6.
Original code complement inverse code