Glam Prestige Journal

Bright entertainment trends with youth appeal.

$\begingroup$

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$.

$\endgroup$ 5

1 Answer

$\begingroup$

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}$

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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