On my midterm, there was a question stating:
Given the decimal values, what is the minimum number of bits required to represent each number in Two's Complement form?
The values were: -26, -1, 10, -15, -4.
I did not get this question right whatsoever, and the solutions are quite baffling.
The only part I really understand is finding the range in which the value is located. For example, -15 would be within the range of [-2^5, 2^5), and -4 would be in the range from [-2^2, 2^2). What steps are needed from here in order to find how many bits were necessary?
I tried finding some pattern to solve it, but it only worked for the first two cases. Here's my attempt:
First I found the range. -2^6 < -26 < 2^6
Then I found the value for 2^6 = 32.
Then I found the difference between the "closest" bound, and the value.
-26 - (-32) = 6
Again, this worked for the first two values by chance, and now I'm stumped as to find the actual relation between the number of bits required for an integer to be represented in Two's complement form, and the actual integer.
Thanks in advance!
Remember that the scheme two's complement can represent both positive and negative integers. Since this problem calls for eight bits, put another bit on the left. The eight-bit two's complement representation of positive 85 is 01010101 .
Show activity on this post. Minimum number of bits required to represent (+32)base10 and (−32)base10 in signed two's compliment form? So to represent +32 we need 7 bits. So to represent −32 we need 7 bits.
The Correct Answer is -128. The smallest integer that can be represented by an 8- bit number in 2's complement form is -128.
First off, you're off on your powers of 2. 32 = 25.
Anyway, I followed you through the first two steps. Your last step doesn't make sense.
So, for each of the numbers you gave: -26, -1, 10, -15, -4.
Got it?
The -1
one is tricky...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With