Recently in the "in-depth understanding of computer systems", learning some of the basic things of programming, still feel very interesting.
Today I see the complement Code section.
The most common form of a computer representation of signed numbers is the complement (s-complement). In this definition, the most effective word is interpreted as negative (negative weight). We use the function B2TW (the abbreviation for Binary to both ' s-complement, the length is W).
The most significant bit xw-1 is also known as the sign bit, and its "weight" is -2w-1, which is the negative number of the weight in the unsigned representation. The sign bit is set to 1 o'clock, which indicates a negative value, and when set to 0, the value is non-negative.
Look carefully at the previous formula, especially the front-xw-12w-1.
The common 32-bit integer, if the value is
11111111 11111111 11111111 11111111
= -1*231 + 1*230 + 1*229 + 1*228 +...+ 1*21 + 1*20
=-231 + (231-1)//Don't ask how the results came, xxx-_-| | Sum formula ....
=-1
Well, what about the others?
11111111 11100011 11011101 11110011
= -1*231 + 1*230 +...+ 1*221 + 1*217 +...+ 1*214 + 1*212 + 1*211 + 1*210 + 1*28+...+ 1*24+ 1*21+ 1*20//less 2/3/9/13/18/19/ 20
= -1*231 + (1*230 + 1*229 + 1*228 +...+ 1*21 + 1*20)-22-23-29-213-218-219-220
=-231 + (231-1) -22 -23 -29 -2- 2- 2-2 20 7>
=-1 -22 -23 -29 -2- 2 -2 + 2
See what's on your mind here?
By the way, the notation of binary expressions of negative numbers is common.
The binary expression of the PNs (int32) is 00000000 00000000 00000000 00100101
-37 of the wording:
First anti-code: 11111111 11111111 11111111 11011010, what is the value?
11111111 11111111 11111111 11011010 = -1-20-22-25 = 37-1
So on the basis of anti-code, we also need +1, in order to get-37 binary code:
11111111 11111111 11111111 11011011 = -1-22-25 = 37
15.04.10-, interesting complements.