1
\$\begingroup\$

I have a problem figuring out why the smallest negative number we can represent in 3 bits, using Signed-2's-Complement is -4.

I understand that in S2C format, we can create numbers from 2x-1-1 (Highest Positive Number) to -2x-1 (Smallest Negative Number).

The problem is that in the S2C representation of -4 which is 100, the MSB is to indicate the sign which means that the magnitude of the number cannot be more than +3 if we tried to calculate the 2's complement in order to find the decimal value of 100 in S2C. For example, the S2C representation of -3 is 101. If we try to take the 2's complement to find the decimal value, the complemented number would be 011 the magnitude of which is 3 and since the original sign of the number we were given was 1, we know that it must have been -3.

The same logic does not apply to -4 or the smallest negative number in S2C form with any number of bits.

I appreciate any help.

\$\endgroup\$
1
  • \$\begingroup\$ -1 is the smallest negative integer, I think you mean "least". \$\endgroup\$ Commented Jan 29, 2023 at 11:23

2 Answers 2

1
\$\begingroup\$

You cannot represent +4 as a 3-bit S2C, so what you're trying to do is a corner case.

You could however convert your 3-bit S2C value into a 4-bit S2C value, then you can apply the usual rules.

  • -4 as a 3-bit S2C value: 100b
  • -4 as a 4-bit S2C value: 1100b (because the MSB is 1, you have to shift in additional 1's)
  • Apply the binary one's complement operator by flipping all bits: 0011b
  • Add one to obtain the 2's complement: 0100b = +4
\$\endgroup\$
1
\$\begingroup\$

Yes, that is true. That means that there is the possibility of an overflow when you negate a 2's complement number.

Of course you could do something strange like work with negative numbers rather than positive and then negate at the end of a calculation if there was some benefit in that.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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