Question

add 8923 and -23890 using 32-bit 2's complement and show all the steps and also verify...

add 8923 and -23890 using 32-bit 2's complement and show all the steps and also verify that the result is true.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Number: 8923
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 8923 successively by 2 until the quotient is 0
   > 8923/2 = 4461, remainder is 1
   > 4461/2 = 2230, remainder is 1
   > 2230/2 = 1115, remainder is 0
   > 1115/2 = 557, remainder is 1
   > 557/2 = 278, remainder is 1
   > 278/2 = 139, remainder is 0
   > 139/2 = 69, remainder is 1
   > 69/2 = 34, remainder is 1
   > 34/2 = 17, remainder is 0
   > 17/2 = 8, remainder is 1
   > 8/2 = 4, remainder is 0
   > 4/2 = 2, remainder is 0
   > 2/2 = 1, remainder is 0
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 10001011011011
So, 8923 of decimal is 10001011011011 in binary
Adding 18 zeros on left hand side of this number to make this of length 32
so, 8923 in 2's complement binary is 00000000000000000010001011011011

Number: -23890
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 23890 successively by 2 until the quotient is 0
   > 23890/2 = 11945, remainder is 0
   > 11945/2 = 5972, remainder is 1
   > 5972/2 = 2986, remainder is 0
   > 2986/2 = 1493, remainder is 0
   > 1493/2 = 746, remainder is 1
   > 746/2 = 373, remainder is 0
   > 373/2 = 186, remainder is 1
   > 186/2 = 93, remainder is 0
   > 93/2 = 46, remainder is 1
   > 46/2 = 23, remainder is 0
   > 23/2 = 11, remainder is 1
   > 11/2 = 5, remainder is 1
   > 5/2 = 2, remainder is 1
   > 2/2 = 1, remainder is 0
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 101110101010010
So, 23890 of decimal is 101110101010010 in binary
Adding 17 zeros on left hand side of this number to make this of length 32
So, 23890 in normal binary is 00000000000000000101110101010010
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   00000000000000000101110101010010 is flipped to 11111111111111111010001010101101
Step 3:. Add 1 to above result
11111111111111111010001010101101 + 1 = 11111111111111111010001010101110
so, -23890 in 2's complement binary is 11111111111111111010001010101110

Adding 00000000000000000010001011011011 and 11111111111111111010001010101110 in binary
00000000000000000010001011011011
11111111111111111010001010101110
-------------------------------------
(0)11111111111111111100010110001001
-------------------------------------
Sum does not produces a carry
So, sum of these numbers in binary is 11111111111111111100010110001001

Verification:
---------------
sum = 11111111111111111100010110001001
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.
   11111111111111111100010110001001 is flipped to 00000000000000000011101001110110
II. Add 1 to above result
00000000000000000011101001110110 + 1 = 00000000000000000011101001110111
III. Now convert this result to decimal value
=> 11101001110111
=> 1x2^13+1x2^12+1x2^11+0x2^10+1x2^9+0x2^8+0x2^7+1x2^6+1x2^5+1x2^4+0x2^3+1x2^2+1x2^1+1x2^0
=> 1x8192+1x4096+1x2048+0x1024+1x512+0x256+0x128+1x64+1x32+1x16+0x8+1x4+1x2+1x1
=> 8192+4096+2048+0+512+0+0+64+32+16+0+4+2+1
=> 14967
Answer: -14967
This is correct since we can verify that 8923+-23890 = -14967
So, there was no overflow.

Add a comment
Know the answer?
Add Answer to:
add 8923 and -23890 using 32-bit 2's complement and show all the steps and also verify...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT