Question

Assume that 151 and 214 are signed 8-bit decimal integers stored in two’s complement format. Calculate...

Assume that 151 and 214 are signed 8-bit decimal integers stored in two’s complement format. Calculate 151 + 214 by adding the two’s complement numbers first and then writing the final result in decimal. Then explain why the final result is very different from 366 (151+214=366). Note that if a number requires more than 8 bits, you need to represent first the number correctly using as many bits as necessary, then keep only the 8 bits, and use the resulting number in the arithmetic operation.
Then,
Calculate 151- 214 by performing binary addition.


Please show all work! Thank you for the help

0 0
Add a comment Improve this question Transcribed image text
Answer #1
1)
Number: 151
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 151 successively by 2 until the quotient is 0
   > 151/2 = 75, remainder is 1
   > 75/2 = 37, remainder is 1
   > 37/2 = 18, remainder is 1
   > 18/2 = 9, remainder is 0
   > 9/2 = 4, remainder is 1
   > 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 10010111
So, 151 of decimal is 10010111 in binary
so, 151 in 2's complement binary is 10010111

Number: 214
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 214 successively by 2 until the quotient is 0
   > 214/2 = 107, remainder is 0
   > 107/2 = 53, remainder is 1
   > 53/2 = 26, remainder is 1
   > 26/2 = 13, remainder is 0
   > 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 11010110
So, 214 of decimal is 11010110 in binary
so, 214 in 2's complement binary is 11010110

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

Verification:
---------------
sum = 01101101
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
=> 1101101
=> 1x2^6+1x2^5+0x2^4+1x2^3+1x2^2+0x2^1+1x2^0
=> 1x64+1x32+0x16+1x8+1x4+0x2+1x1
=> 64+32+0+8+4+0+1
=> 109
Answer: 109
151+214 must be 365
This is not correct since we can verify that 151+214 not equals 109
So, there was an overflow.

1)
Number: 151
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 151 successively by 2 until the quotient is 0
   > 151/2 = 75, remainder is 1
   > 75/2 = 37, remainder is 1
   > 37/2 = 18, remainder is 1
   > 18/2 = 9, remainder is 0
   > 9/2 = 4, remainder is 1
   > 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 10010111
So, 151 of decimal is 10010111 in binary
so, 151 in 2's complement binary is 10010111

Number: -214
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 214 successively by 2 until the quotient is 0
   > 214/2 = 107, remainder is 0
   > 107/2 = 53, remainder is 1
   > 53/2 = 26, remainder is 1
   > 26/2 = 13, remainder is 0
   > 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 11010110
So, 214 of decimal is 11010110 in binary
So, 214 in normal binary is 11010110
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   11010110 is flipped to 00101001
Step 3:. Add 1 to above result
00101001 + 1 = 00101010
so, -214 in 2's complement binary is 00101010

Adding 10010111 and 00101010 in binary
    10010111
    00101010
-------------
 (0)11000001
-------------
Sum does not produces a carry
So, sum of these numbers in binary is 11000001

Verification:
---------------
sum = 11000001
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.
   11000001 is flipped to 00111110
II. Add 1 to above result
00111110 + 1 = 00111111
III. Now convert this result to decimal value
=> 111111
=> 1x2^5+1x2^4+1x2^3+1x2^2+1x2^1+1x2^0
=> 1x32+1x16+1x8+1x4+1x2+1x1
=> 32+16+8+4+2+1
=> 63
Answer: -63
This is correct since we can verify that 151+-214 = -63
So, there was no overflow.
Add a comment
Know the answer?
Add Answer to:
Assume that 151 and 214 are signed 8-bit decimal integers stored in two’s complement format. Calculate...
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