The problem is to convert $32$ to $6$-bit two's complement or note that the range would overflow.

For $32$, I have: $100000$.

How does this overflow? Is it because the 1 means negative, so it would be $0100000$ but the space cannot accommodate this? But the notes say the max positive number is $2^5 - 1 = 31$.

  • $\begingroup$ The range you want to cover with 6 bits is from $-2^5$ to $2^5-1$, is it? $\endgroup$ – mike239x Feb 18 '18 at 22:33
  • $\begingroup$ Where does the power 5 come from? $\endgroup$ – user855911 Feb 18 '18 at 22:45
  • $\begingroup$ Well, 5 = 6-1. Just like 32-bit system stores numbers from $-2^{31}$ to $2^{31}-1$. $\endgroup$ – mike239x Feb 18 '18 at 22:49
  • $\begingroup$ My question was about following: with 6 bits you can either store numbers in range $[−2^5, 2^5−1]$, or numbers in range $[0,2^6-1]$, or technically speaking you can store an element from a fixed set with $2^6$ elements. So the question if the range would overflow is a bit weird without clarification, what your range is. $\endgroup$ – mike239x Feb 18 '18 at 22:52
  • 1
    $\begingroup$ @mike239x: the question says that the representation is 6-bit two's complement, so the range is $-2^5$ to $2^5-1$. The OP's explanation for the overflow is essentially correct: $32_{10} = 100000_{2}$ and $100000$ is interpreted as $-32_{10}$ in 6-bit two's complement. $\endgroup$ – Rob Arthan Feb 18 '18 at 23:02

As you say, in twos complement the first bit represents the sign and the rest of the bits represent the number. Writing $32_{10}=100\ 000_2$ is not legal in twos complement as the leading bit being $1$ represents a negative number and $32_{10}$ is not negative. In $6$ bit twos complement the largest positive number you can represent is $31_{10}=011\ 111$. As you count down you get to $)_{10}=000\ 000$, then roll over to $-1_{10}=111\ 111$. As you keep counting down you finally get to $-32_{10}=100\ 000$, which is the most negative number you can represent. Your proposed representation of $32_{10}=100\ 000$ would be read as $-32_{10}$


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.