The various values in the computer's representation is called the machine number, the machine number uses the binary number to represent the data, the data sign also uses 0 and one to represent. In order to facilitate the operation, the number of symbols of the machine can be used in the original code, anti-code, complement, shift code and other coding methods.
Note: The following rules are the machine word length is 8 (that is, 8 bits is used to represent the data) to illustrate .
Original Code
⊙ positive number: If ① first write the data to represent, ② sign bit (first) write on 0,③ if there is a vacancy with 0, such as x=22=10110b, then [X] original = 00010110;
⊙ negative Number: If ① first write the data to be expressed, ② first write on 1,③ if there is a vacancy with 0 complement, such as x=-27=-11011b, then [X] original = 10011011.
Anti-code
⊙ positive number: The inverse code equals the original code, such as x=10110, then [X] anti-=[x] original = 00010110;
⊙ Negative Number: For example, on the basis of the original code, the ④ sign bit (first) unchanged, ⑤ the other bits of the bitwise negation (0 to 1, 1 to 0), such as x=-11011, then [X] Original =10011011,[x] anti = 11100100.
complement
⊙ positive: The complement is equal to the original code and anti-code, such as x=10110, then [X] complement =[x] anti-=[x] original = 00010110;
⊙ negative number: On the basis of anti-code, ⑥ let the Anti-code plus 1, such as x=-11011, then [X] original =10011011,[x] anti-=11100100,[x] complement = 11100101.
Shift Code
Positive and negative numbers of the shift code, are on the basis of anti-code, so that the anti-code sign bit counter, that is, the number of the shift code. such as x=-11011, then [X] original =10011011,[x] anti-=11100100,[x] fill =11100101,[x] Shift = 01100101.
Add:conversion of the original code, inverse code, complement, and shift code of decimals
The conversion between the original code, the inverse code, the complement, and the shift code is basically only a few differences between positive and negative conversions, when a decimal is encountered, only the decimal is represented as a binary, and the conversion mode is the same as a positive number. As X=0.25=0.01,[x] Original =0.0100000,[x] anti =0.1011111,[x] Fill =0.1100000,[x] Shift = 1.1100000.
Super Simple small example to uncover the mysteries of machine numbers-original code, anti-code, complement, shift code