Question

In: Computer Science

add -54 and -101 using 9 bit 2's complement

add -54 and -101 using 9 bit 2's complement

Solutions

Expert Solution

Number: -54
Let's convert this to two's complement binary
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 54 successively by 2 until the quotient is 0
   > 54/2 = 27, remainder is 0
   > 27/2 = 13, remainder is 1
   > 13/2 = 6, remainder is 1
   > 6/2 = 3, remainder is 0
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 110110
So, 54 of decimal is 110110 in binary
Adding 3 zeros on left hand side of this number to make this of length 9
So, 54 in normal binary is 000110110
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   000110110 is flipped to 111001001
Step 3:. Add 1 to above result
111001001 + 1 = 111001010
so, -54 in 2's complement binary is 111001010

Number: -101
Let's convert this to two's complement binary
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 101 successively by 2 until the quotient is 0
   > 101/2 = 50, remainder is 1
   > 50/2 = 25, remainder is 0
   > 25/2 = 12, remainder is 1
   > 12/2 = 6, remainder is 0
   > 6/2 = 3, remainder is 0
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 1100101
So, 101 of decimal is 1100101 in binary
Adding 2 zeros on left hand side of this number to make this of length 9
So, 101 in normal binary is 001100101
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   001100101 is flipped to 110011010
Step 3:. Add 1 to above result
110011010 + 1 = 110011011
so, -101 in 2's complement binary is 110011011

Adding 111001010 and 110011011 in binary
    111001010
    110011011
--------------
 (1)101100101
--------------
Sum produces a carry of 1. We can ignore that carry.
So, sum of these numbers in binary is 101100101

Verification:
---------------
sum = 101100101
since left most bit is 1, this number is negative number.
so, follow these steps below to convert this into a decimal value.
I. first flip all the bits. Flip all 0's to 1 and all 1's to 0.
   101100101 is flipped to 010011010
II. Add 1 to above result
010011010 + 1 = 010011011
III. Now convert this result to decimal value
=> 10011011
=> 1x2^7+0x2^6+0x2^5+1x2^4+1x2^3+0x2^2+1x2^1+1x2^0
=> 1x128+0x64+0x32+1x16+1x8+0x4+1x2+1x1
=> 128+0+0+16+8+0+2+1
=> 155
Answer: -155
This is correct since we can verify that -54+-101 = -155
So, there was no overflow.

Related Solutions

add -54 and -101 using 9 bit 2's complement
add -54 and -101 using 9 bit 2's complement
add -54 and -101 using 9 bit 2's complement
add -54 and -101 using 9 bit 2's complement
add -19 and 79 using 16-bit 2's complement format
add -19 and 79 using 16-bit 2's complement format
add -19 and 79 using 16-bit 2's complement format
add -19 and 79 using 16-bit 2's complement format
add -19 and 79 using 16-bit 2's complement format
add -19 and 79 using 16-bit 2's complement format
add the following numbers using 16-bit 2's complement. show all the steps and calculations. Please also...
add the following numbers using 16-bit 2's complement. show all the steps and calculations. Please also show steps to verify that the answer is correct. -7493 and -6372
Convert -18 to 8-bit sign magnitude, 1's complement and 2's complement.
Convert -18 to 8-bit sign magnitude, 1's complement and 2's complement.
Convert -18 to 8-bit sign magnitude, 1's complement and 2's complement.
Convert -18 to 8-bit sign magnitude, 1's complement and 2's complement.
Convert -18 to 8-bit sign magnitude, 1's complement and 2's complement.
Convert -18 to 8-bit sign magnitude, 1's complement and 2's complement.
Convert -122 to 8-bit sign magnitude, 1's complement and 2's complement
Convert -122 to 8-bit sign magnitude, 1's complement and 2's complement
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT