Question

In: Computer Science

add -19 and 79 using 16-bit 2's complement format

add -19 and 79 using 16-bit 2's complement format

Solutions

Expert Solution

Number: -19
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 19 successively by 2 until the quotient is 0
   > 19/2 = 9, remainder is 1
   > 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 10011
So, 19 of decimal is 10011 in binary
Adding 11 zeros on left hand side of this number to make this of length 16
So, 19 in normal binary is 0000000000010011
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   0000000000010011 is flipped to 1111111111101100
Step 3:. Add 1 to above result
1111111111101100 + 1 = 1111111111101101
so, -19 in 2's complement binary is 1111111111101101

Number: 79
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 79 successively by 2 until the quotient is 0
   > 79/2 = 39, remainder is 1
   > 39/2 = 19, remainder is 1
   > 19/2 = 9, remainder is 1
   > 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 1001111
So, 79 of decimal is 1001111 in binary
Adding 9 zeros on left hand side of this number to make this of length 16
so, 79 in 2's complement binary is 0000000001001111

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

Verification:
---------------
sum = 0000000000111100
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
=> 111100
=> 1x2^5+1x2^4+1x2^3+1x2^2+0x2^1+0x2^0
=> 1x32+1x16+1x8+1x4+0x2+0x1
=> 32+16+8+4+0+0
=> 60
Answer: 60
This is correct since we can verify that -19+79 = 60
So, there was no overflow.

Related Solutions

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 -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 -54 and -101 using 9 bit 2's complement
add -54 and -101 using 9 bit 2's complement
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