binarydecimaltwos-complementones-complement

Converting Decimal to Two's-Complement


Instructions: Convert these decimal numbers to 5-bit 2's-complement form, if possible. If not possible, explain why this is so.

(16) base 10

According to the online converter:

From what I understand,

If decimal is positive:

If decimal is negative:

Since 16 is positive, I simply converted it to binary by repeated division yielding (10000) base 2.

I no longer padded 0's since it is already 5-bits (containing 5 digits).

Can somebody explain to me why the online converter is returning an error (which also I strongly believe is the correct answer)?


Solution

  • With 5 bits you can represent up to 2^5 different numbers, since you want negative and positive numbers the range is -16 to +15.

    so you get error since 16 is out of the range for 5 bits. Change to 6 bits and it should work