$2’s$ complement of $-100$ is:
- $00011100$
- $10011101$
- $10011100$
- $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?
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:
$$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:
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.