Learned a good long time, today finally really understand the computer's negative memory, finally understand the operation of the complement.
Many of us in the beginning of learning about the knowledge of the time, most of the head, especially in relation to the binary complement expression, as well as the complement and the decimal negative integer conversion between the time, after learning all feel dizzy. Maybe some people feel good after learning, but when asked N-bit binary complement of the decimal range, he fainted. For example, 8-bit binary complement of the decimal notation range is: -128~127, why. I just opened the access system is to learn the digital circuit, I do not remember at that time I put the complement that section to see how many times, also do not know how many books to read, eventually did not fully understand. Until today, I saw a once also had this headache of Daniel's explanation, I just get the understanding.
Now let's get to the point.
The first thing to say is that negative numbers are stored in the computer: Negative numbers are stored in the computer in the context of the complement.
The second thing to say is that the binary representation of the original code, the inverse code, the complement, today is mainly about the complement. As for the original code and counter code, it is easy to understand, and is not the focus of today, this is not to repeat.
1, the complement of the operation:
Decimal binary is known
Finding the binary complement of positive integers
In addition to 2, until the quotient is zero, the remainder flashback arrangement
Finding the binary of negative integers
First the binary code of the absolute value of the negative number is obtained, then all the bits of the binary code are reversed, plus 1, then the left complement 1 as the symbol bit. If you require more bits to be represented, then the corresponding 1 on the left side of the sign bit is OK. The following casually enumerated some numbers, the other corresponding imitation on the line:
Negative:-5 Absolute value: 5 The absolute value of the binary code: 1012-in-code: 102 in-system complement: 011 left another 1 is negative, that is 1011 = (-1) *8+0*4+1*2+1*1 =-5
Complement 8-bit representation: 11111011 = (-1) (2^7) +1 (2^6) +1* (2^5) +1* (2^4) ... =-5
Complement 16 bit 16 binary notation: FFFB =-5
The following number of examples of the calculation process IBID.: Negative:-14 absolute Value: 14 absolute value of the binary code: 11,102 binary Code: 12 in-system complement: 10010 =-14
Complement 8 bit 16 binary notation: F2 =-14
Complement 16 bit 16 binary notation: FFF2 =-14
Negative:-27 absolute Value: 27 The binary code of absolute value: 110,112 binary code: 1002 Complement: 100101 =-27
Complement 8 bit 16 binary notation: E5 =-27
Complement 16 bit 16 binary notation: FFE5 =-27
Negative number:-79 absolute Value: 79 The binary code of absolute value: 10,011,112 binary code: 1,100,002 in-system complement: 10110001
Complement 8-bit 16-binary representation: B1
Complement 16-bit 16-binary representation: FFB1
Negative number:-127 absolute Value: 127 The binary code of absolute value: 11,111,112 binary code: 00000002 in-system complement: 10000001
Complement 8 bit 16 binary representation: 81
Complement 16-bit 16-binary representation: FF81
Negative Number:-128 Absolute Value: 128 The binary code of absolute value: 100,000,002 binary code: 11,111,112 in-system complement: 10000000
Complement 8 bit 16 binary representation: 80
Complement 16-bit 16-binary representation: FF80
All right, just hold on so much, and then you'll be long-winded. Next, the decimal representation range of the N-bit binary complement in the computer.
2. Decimal representation range of n-bit binary complement
8-bit binary complement maximum can be represented by a positive integer of 127, that is, binary 01111111, where the leftmost 0 is a sign bit, indicating a positive number. The 8-bit binary complement minimum can be expressed as a negative integer of 128, that is, the binary is 10000000, where the leftmost 1 is a sign bit, indicating a negative number, that is (-1) * (2^7).
others and so on.