179k views
5 votes
xpress the negative value -22 as a 2's complement integer, using eight bits. Repeat it for 16 bits and 32 bits. What does this illustrate with respect to the properties of sign extension as they pertain to 2's complement representation?  8 bit The 8-bit binary representation of 22 is 00010110. So, -22 in 2’s complement form is (NOT (00010110) + 1) = (11101001 + 1) = 11101010

1 Answer

2 votes

Answer:

Step-by-step 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

User BLT
by
3.9k points