Answer:
Explanation:
A negative binary number is represeneted by its 2's complement value. To get 2's complement, you just need to invert the bits and add 1 to it. So the formula is:
Β twos_complement = ~val + 1
So you start out with 22 and you want to make it negative.
22ββ = β0001 0110β¬β Β Β
~22ββ = β1110 1001β¬β Β inverting the bits
~22ββ + 1 = β1110 1010β¬β Β adding 1 to it.
so -22ββ == ~22ββ + 1 == β1110 1010β¬β
Do the same process for 16-bits and 32-bits and you'll find that the most significant bits will be padded with 1's.
-22ββ = β1110 1010β¬β Β Β 8-bits
-22ββ = β1111 1111 1110 1010β¬β¬β Β Β 16-bits
-22ββ = ββ1111 1111 1111 1111 1111 1111 1110 1010β¬β¬β¬β Β 32-bits