1) Original Code representation
The original code notation is a simple representation of the number of machines. The sign bit with 0 for a positive sign, with: to denote a minus, the value is generally expressed in binary form. With a number of x, the original code is denoted as [x] original.
For example, x1= +1010110
X2= 11,001,010
The original code is written as:
[X1] Original =[+1010110] Original =01010110
[X2] Original =[-1001010] Original =11001010
In the original code notation, there are two representations of 0:
[+0] Original =00000000
[-0] Hara =10000000
2) Complement expression
The complement of the number of machines can be obtained from the original code. If the number of machines is positive, then the number of the machine is the same as the original code, if the number of machines is negative, then the number of the machine is the complement of its original code (except for the sign bit) to take the inverse, and in no place plus 1 to get. With a number x, the complement of x is denoted as [x] complement.
For example, [x1]=+1010110
[X2]= 11,001,010
[X1] Original =01010110
[X1] Complement =01010110
[X1] Original =[x1] complement =01010110
[X2] Original = 11001010
[X2] Complement =10110101+1=10110110
(3) Anti-code notation
The inverse code of the number of machines can be obtained from the original code. If the number of machines is positive, then the inverse code of the machine number is the same as the original code, if the number of machines is negative, then the counter code of the number of the machine is the original code (except for the sign bit) you get. With a number x, the anti-code representation of x is denoted as [x] reversed.
Example: x1= +1010110
X2= 11,001,010
[X1] Original =01010110
[X1] Anti-=[X1] original =01010110
[X2] Original =11001010
[X2] Anti-=10110101
The inverse code is usually used as the intermediate form of the process of the complement, that is, in the non-position of the inverse code of a negative number plus 1, we get the complement of the negative number.
Example 1. Known [x] original = 10011010, [x] complement.
The analysis is as follows:
The principle of [x] in the original [x] is: If the number of machines is positive, [x] the original =[x] complement, if the number of machines is negative, then the number of the machine is the complement of its original code (except the sign bit) all the bit negation, and then in the non-1 and obtained. Now given the number of machines is negative, it has [X] complement =[x] original 11, namely
[X] Original =10011010
[X] Anti-=11100101+1
[X] Complement =11100110
Example 2. Known [x] complement = 11100110, [x] original.
The analysis is as follows:
For a positive number of machines, [X] original =[x] complements the
For machine number is negative, there is [X] original =[[x] Complement
Now given is a negative number, so there are:
[X] Complement =11100110
[[X] complement] anti-=10011001+1
[[[X] complement] complement =10011010=[x] Original +1
[[[X] complement] complement =10011010=[x] Original
Summing up, the original code (for negative, positive time is unchanged) all take the inverse is to get anti-code, anti-code plus
"1" got the complement, it's that simple.
Note: the inverse (~) is an operation, that is, to find a number of the inverse code. such as int a = 1; ~a is-2. (function: Can place the |~a| position 0)
C Language of the original code, anti-code, complement