I. For positive numbers, the original code and the reverse code are the same, and all are positive numbers. For negative numbers, the original code is the binary value of the absolute value of X when the symbol bit is 1. The anti-code is that the symbol bit is 1, and the other bit is the reverse of the original code. The complement Code indicates that the symbol bit is 1, the other bit is the reverse of the original code, and the unbitwise value is 1. That is to say, the complement of a negative number is that its anticode is not added with 1. The bitwise is the complement of the reversed symbol.1011 original code: 01011 reverse code: 01011 // when positive, reverse code = original code: 01011 // when positive, complement = original code: 11011 // original number + 2017-1011 original code: 11011 reverse code: 10100 // when the negative number is used, the reverse code is the original code and the reverse code is 10101 // negative, and the reverse code is the original code + 1 shift code: 00101 // The original number + 100000.1101 original code: 0.1101 reverse code: 0.1101 // when positive, back code = original code: 0.1101 // when positive, complement = original code: 1.1101 // original number + 1-0.1101 original code: 1.1101 reverse code: 1.0010 // when negative, when the anti-code is the original code and the anti-complement code is: 1.0011 // negative, the complement code is the original code to get the anti-+ 1 shift code: 0.0010 // The original number + 1
Source code of 0
+0: 0000 0000 -0 :1000 0000
0 Complement
+0: 0000 0000 -0: 0000 0000
0)
+0&-0:1000 0000
2: In the computer, only addition operations are actually required. subtraction operations must also be converted to addition operations, multiplication to addition operations, and division to subtraction operations. 3. In a computer, any binary with a symbol is computed and stored in the form of its complement code. The reason is that the Code is supplemented, instead of the original code and the reverse code, because the computer has a problem in processing the original code and the reverse code with a symbol. The Code-filling method simplifies the operation rules by enabling the symbol bit and the valid value part to join the operation. on the other hand, the subtraction operation is converted to the addition operation, which further simplifies the line design of the generator in the computer. 4. The complement addition and subtraction Formula 1 ): fill addition formula [x + y] fill = [x] fill + [y] fill 2 ): complement subtraction formula [X-Y] fill = [x] fill-[y] fill = [x] fill + [-y] fill where: [-y] fill is called negative complement, the method for calculating the negative complement is: reverse the complement of every bit (including the matching bit), and not add 1. 5. Calculate the number of completed codes by the complement code. The operation of the source code is divided into two situations: If the sign bit of the complement code is "0", it indicates a positive number, so the complement is the original code of the number. If the sign bit of the complement code is "1", it indicates a negative number. The operation to calculate the source code can be: the sign bit is 1; the rest will be reversed, and then the entire number is added to 1.
Article transferred from: http://blog.csdn.net/cc_lq/article/details/7359584