-2

If we use seven-bit two's complement binary representation for integers, what is The number of integers (things) that can be represented in this way? The smallest (most) negative integer that can be represented in this way? The largest positive integer that can be represented in this way?

  • This is a CS homework question that I am having trouble answering and explaining. Any help would be appreciated.

3 Answers3

0

So its really easy

Counting in binary usually goes like

>00000000 (8) = 0
>00000001 (8) = 1
>00000010 (8) = 2
>00000011 (8) = 3
>etc...etc.

In 7 bit the last bit is what decides if its a negative or positive

1 being negative and 0 being positive

> 10000000 = -128
> 10000001 = -127
> 10000010 = -126
> On...and on...
> 11111111 = -1
> 00000000 = 0
> 00000001 = 1
> 01111111 = 127

So lowest you can go is -128

Highest you can go is 127

ArcSet
  • 6,518
  • 1
  • 20
  • 34
  • Thank you so much. I have been trying to catch up in this class, because my books came in late, and I think my brain just got overwhelmed. The answer you gave makes sense and I appreciate it so much. – Alexis Lanciani Sep 21 '17 at 23:37
0

Approved answer is not correct. With 7-bits of 2's complement, it could range from -64 to 63. (traditionally, 7 bits can only go up to 2^n-1 which is 128 but MSB is reserved for sign, so we could have 6 bits to represent the data. We will be getting 64 positive and 63 negative values and answer should be -64, 63.)

No, because in two's complement, the most significant bit is the sign bit. 0000001 is +1, a positive number.

That is why the range of two's complement 7-bit numbers is -64 to 63, because 64 is not representable (it would be negative number otherwise).

The most negative number is 1000000. The leading 1 tells you it's negative, and to get the magnitude of the number, you flip all the bits (0111111), then add one (1000000 = 64). So the resulting number is -64 thru 63.

amitola
  • 16
  • 2
0

For largest positive integer in 2's complement use the formula (2^(n-1)-1) That is (2^(7-1)-1)=63 For the smallest use -2^n-1 That is -2^7-1=-64