I am a new rookie in computer engineering, not sure how to get the 2's complement representation of -32 in 6-bits, because -32 is reaching limit.
Asked
Active
Viewed 3,165 times
1 Answers
1
For 2's complement, the easiest method is this one:
- write the positive value (here 32) in binary form
- begin to read from the right, and skip all the zeroes until you find the first 1
- leave the one as it is
- keep going left, this time inversing each number (1 => 0, 0 => 1)
Example: -7. 7 is 000111
. The first 1 is on the right, keep it then inverse the rest. You get 111001
.
So in your example, you can't represent -32 with six bits, since the first one is also the last one. Si it will be read 100000
=> -011111
=> 31.
You need at least one more bite to avoid overflow (the last bite on the left being the "sign": 0 for positive, 1 for negative).

Derlin
- 9,572
- 2
- 32
- 53