Given this question :

What range of decimal numbers can be represented with an 11-bit two's-complement 
a)  -2048 to 2047 
b)  -2048 to 2048 
c)  -1024 to 1023 
d)  -1024 to 1024 

I know the answer is C, but i don't know how we can acheive this result

I'm aware of converting binary to decimal/ hexa and vice versa, also calculating one's complement and two's complement from a binary

I'm very new to this, forgive my humble mind


A good way to think of 2's complement representations of signed integers is that the most significant bit (MSB) represents the negative of the value that the bit would ordinarily represent in an unsigned integer.

Let's consider 8-bit integers. The unsigned integer has bits with values $$\begin{array}{*{20}{c}} {{\text{Bit}}}&7&6&5&4&3&2&1&0 \\ {{\text{Value}}}&{128}&{64}&{32}&{16}&8&4&2&1 \end{array}$$ while the signed integer (in the 2's complement representation) has bits with values $$\begin{array}{*{20}{c}} {{\text{Bit}}}&7&6&5&4&3&2&1&0 \\ {{\text{Value}}}&{-128}&{64}&{32}&{16}&8&4&2&1 \end{array}$$

To get the decimal value, we simply add together the values associated with all $1$ bits. So for example, the binary string $10100100$ as an unsigned integer would be $$128 + 32 + 4 = 164$$ while the same string as a signed integer would be $$-128 + 32 + 4 = -92$$ Now we ask: what are the lowest and highest values we can possibly get for the signed integer?

For the lowest value, obviously what we want to do is set the one negative bit (the MSB, or 'sign bit') corresponding to $-128$ to $1$ and all other bits corresponding to positive values to zero. Thus the lowest value we can obtain is the value of the MSB, or in this case, $-128$.

For the highest value, we obviously want to zero the MSB and set all other bits to 1, which gets us a value of $$64 + 32 + 16 + 8 + 4 + 2 + 1 = 127$$ Hence the range of signed 3-bit integers is $-128$ to $127$.

The same logic holds for an 11-bit signed integer, only now with 11 bits. Our value table is

$$\begin{array}{*{20}{c}} {{\text{Bit}}}&{10}&9&8&7&6&5&4&3&2&1&0 \\ {{\text{Value}}}&{-1024}&{512}&{256}&{128}&{64}&{32}&{16}&8&4&2&1 \end{array}$$ and by a similar procedure as above, we find that the minimum obtainable value is $-1024$ and the maximum is $1023$.

  • $\begingroup$ very nice answer , thanks $\endgroup$ – f855a864 Aug 15 '14 at 7:54

If the number is stored in $n$ bits, the first bit, the sign bit, doesn't store any digits, so the total number of bits storing digits is $n-1$. $n$ bits can store $2^n$ different numbers. Since the sign bit doesn't store a digit $2^{n-1}$ represents the number of numbers that can be stored in either positive or negative numbers. Because in two's compliment zero counts as a positive number then the highest positive number is $2^{n-1}-1$, since negatives don't have this restriction and $1$ followed by $n-1$ zeros counts as a negative number there are $2^n$ negative numbers and the lowest is $-2^{n-1}$.

(I hope you understood that explanation)

IE: assuming 4 bit numbers (for simplicity):

The highest positive number is $0111$ or $7$ or $2^{n-1}-1$ or $2^3-1$

The lowest negative number is $1000$ or $-8$ or $-2^{n-1}$ or $-2^3$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.