0
$\begingroup$

Minimum number of bits required to represent $(+32)_{base10}$ and $(-32)_{base10}$ in signed two's compliment form?

My attempt:

32 = 0100000 ( 1st zero - sign bit as positive)

So to represent +32 we need 7 bits

-32 = 1100000 (1st bit 1 - sign bit as negative)

So to represent -32 we need 7 bits

But answer is given as 6 bits to store -32 and 7 bits to store +32(positve case i understood, negative in my opinion it should be 7 bits). His reason - one 1 bit enough to represent negative number. I am confused. Please clarify here

Also i have following Questions:-

Can we say number of bits required to represent a negative number is strictly less than( or less than equal to) number of bits required to represent that corresponding positive number?

how can we generalise minimum number of bits required to represent a given positive and negative number say +N and -N in signed magnitude representation, signed 1's complement notation and signed two's compliment notation.

$\endgroup$
  • $\begingroup$ Your question is not very clear about the actual range of numbers that should be stored. As it stands, the maximum number of bits to represent only $-32$ and $+32$ is a single bit. I guess this is not what you are asking for. If you want to store any number in that range (inclusively), you'd need 7 bits. (32 (negative values) + 1 (zero) + 32 (positive values)). For a 6-bit solution, you'd have to drop the $+32$. $\endgroup$ – siracusa Nov 24 '19 at 10:09
  • $\begingroup$ sir 0 is a bit, 1 is also a bit. Minimum number of bits required to store +32(0100000) is 7 bits. Right most bit 0 to indicate sign bit. I am asking number of bits required to store -32 in signed two complement form, signed 1 complement form and signed magnitude form $\endgroup$ – Nascimento de Cos Nov 24 '19 at 11:59
1
$\begingroup$

The representations of the numbers as 6-bit two's complement binaries are \begin{align} +32_{10} &= 10\,0000_2\\ -32_{10} &= \overline{10\,0000}_2 + 1_2\\ &= 01\,1111_2 + 1_2\\ &= 10\,0000_2 \end{align} which would give the same representation for both numbers. That means you cannot use 6-bits numbers to represent both values using two's complement.

For 7-bit binaries it works, however: \begin{align} +32_{10} &= 010\,0000_2\\ -32_{10} &= \overline{010\,0000}_2 + 1_2\\ &= 101\,1111_2 + 1_2\\ &= 110\,0000_2 \end{align} As you can see, the most significant bit represents the sign of the number.


Another perspective on your question: What is the biggest positive/smallest negative number you can store in an $n$-bit two's complement binary? Then the answer is $2^{(n-1)}-1$ for the biggest positive and $-2^{(n-1)}$ for the smallest negative number.

That means that a 6-bit binary can hold values $-32, \ldots, 31$ and a 7-bit binary values $-64, \ldots, 63$. The number $-32$ then fits into the range of 6-bit binaries, while $+32$ doesn't. You'd need one more bit for the latter.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ thank you sir, understood it now. $\endgroup$ – Nascimento de Cos Nov 24 '19 at 12:42
0
$\begingroup$

There are 65 values x with -32 <= x <= +32. You cannot represent 65 values in 6 bits. Either you misread the question, or the answer 6 is wrong.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ sir Qn is not wrong. Question is - Minimum number of bits required to represent (+32)base10 and (−32)base10 in signed two's compliment form? This is a question asked in a competetive exam $\endgroup$ – Nascimento de Cos Nov 24 '19 at 11:55

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.