1

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.

Ali A
  • 11
  • 1

2 Answers2

1

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
Velvel
  • 3,591
  • 3
  • 12
  • 30
1

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.

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842