$2’s$ complement of $-100$ is:

3.2k Views Asked by At

$2’s$ complement of $-100$ is:

  1. $00011100$
  2. $10011101$
  3. $10011100$
  4. $11100100$

My attempt:

Decimal $100$ into binary : $01100100$

Decimal $-100$ into binary : $2's$ complement of $01100100=10011011+1=10011100$

$2's$ complement of $-100$ : $2's$ complement of $10011100=01100011+1=01100100$

Sorry, I'm confused what should be answer $10011100$ or $01100100$

I guess it should be $01100100$, however it doesn't match in given options.

Can you explain it, please?

1

There are 1 best solutions below

0
On BEST ANSWER

The answers give part of the question, we are using $8$-bit representation, which allows us to have a range for $8$-bit signed numbers from $-128$ to $127$ (always be careful with this).

That is, the largest signed number we can represent is $2^{n-1}$, where $n = 8$ in this case, so the largest negative number we can represent with $8$-bits is $-128$.

Convert $-100$ to $2's$-complement:

  • $100$ decimal-to-binary: $100_{10} = 110~0100_2$
  • Pad to $8-$bits: $0110~0100$
  • Negate the number by inverting the bits and adding $1$, so:

$$0110~0100 \rightarrow 1001~1011 + 1 \rightarrow \bbox[5px,border:2px solid red]{1001~1100}$$

The process to go backwards to convert a negative two's complement number back to decimal is:

  • Flip all the bits
  • Add $1$, and
  • Interpret the result as a binary representation of the magnitude and add a negative sign

Try this on the above result and make sure you understand how to go both ways.

Lastly, try using hex and seeing if you can do it that way, it is typically easier, but you must always be careful.