Guidance:
In a computer system, all values are represented (stored) by supplementary codes ).
The main reason is that the complement code can be used to process the symbol bit and other digits in a unified manner. At the same time, the subtraction can also be processed by addition. The other two are supplemented.
If the highest bit (symbol bit) has a forward bit, the carry is discarded.
2. The conversion process of the complement code is almost the same as that of the original code.
The value complement representation is also divided into two situations:
(1) positive complement: the same as the original code.
For example, the complement code of + 9 is 00001001.
(2) Complement of negative numbers: the sign bit is 1, and the rest is the original code of the absolute value of the number is reversed by bit; then the whole number is added to 1.
For example, the-7 complement: because it is a negative number, the symbol bit is "1", the whole is 10000111; the other seven digits are the absolute value of-7 + the original code of 7
The bitwise decimal value of 0000111 is 1111000, and the value of-7 is 11111001.
If you know the complement of a number, you can perform the following operations on the source code:
(1) If the sign bit of the complement code is "0", it indicates a positive number. Therefore, the complement code is the original code of the number.
(2) If the sign bit of the complement code is "1", it indicates a negative number. The operation to evaluate the source code can be: the sign bit is 1.
And then add 1 to the entire number.
For example, if a complement code is known as 11111001, the original code is 10000111 (-7): Because the symbol bit is "1", it indicates a negative
The number, so the bit remains unchanged, still "1"; the other 7 digits are reversed to 1111001; Add 1, so it is 0000110.
In the "Idle original code, reverse code, and complement code" file, we did not mention a very important concept "model ". Here I will give a brief introduction to the "model"
Concept:
"Module" refers to the counting range of a metering system. Such as clock. A computer can also be seen as a metering machine, and it also has a measurement model.
There is a "MODULE ". For example:
The Metering range of the clock is 0 ~ 11, modulo = 12.
The N-bit computer metering range is 0 ~ 2 (n)-1, modulo = 2 (n ). [Note: N indicates the Index]
The "module" is essentially the amount of overflow produced by the metering device. Its value cannot be expressed on the metering device, and the metering device can only represent the output mode.
Remainder. Any metered tool with modulus can be reduced to addition.
For example, if the current hour hand points to 10 and the exact time is 6, there are two ways to adjust the time:
One is a four-hour switch, that is, 10-4 = 6.
The other is to distribute the traffic for 8 hours: 10 + 8 = 12 + 6 = 6
In a 12-mode system, the addition of 8 is the same as the subtraction of 4. Therefore, any subtraction operation can be replaced by the addition of 8.
For "modulo", 8 and 4 complement each other. In fact, in a 12-Mode System, 11, and 6 both have this feature.
. The common feature is that the sum of the two equals the modulo.
Computers have the same concept and method. For N-bit computers, if n = 8, the maximum number can be 11111111.
Addition 1 is called 100000000 (9 bits), but because there are only 8 bits, the highest bits 1 is naturally lost. 00000000 again, so the 8-bit binary system
The modulo is 2 (8 ). In such a system, the subtraction problem can also be converted into an addition problem. You only need to use the corresponding population to represent the reduction.
. The complement number is used to process the computer logarithm, that is, the complement code.
This article is transferred from
Http://jinweijingjing.blog.sohu.com/82869658.html