Question

In: Computer Science

using 8 bits and 2s complement integer arithmetic, show how a processor would calculate 63 -...

using 8 bits and 2s complement integer arithmetic, show how a processor would calculate 63 - 17

Solutions

Expert Solution

Number: 63
Let's convert this to two's complement binary
63
Since this is a positive number. we can directly convert this into binary
Divide 63 successively by 2 until the quotient is 0
   > 63/2 = 31, remainder is 1
   > 31/2 = 15, remainder is 1
   > 15/2 = 7, remainder is 1
   > 7/2 = 3, remainder is 1
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 111111
So, 63 of decimal is 111111 in binary
so, 63 in 2's complement binary is 00111111

Number: -17
Let's convert this to two's complement binary
-17
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 17 successively by 2 until the quotient 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 10001
So, 17 of decimal is 10001 in binary
So, 17 in normal binary is 00010001
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   00010001 is flipped to 11101110
Step 3:. Add 1 to above result
11101110 + 1 = 11101111
so, -17 in 2's complement binary is 11101111

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

Verification:
---------------
sum = 00101110
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
Converting 101110 to decimal
101110
=> 1x2^5+0x2^4+1x2^3+1x2^2+1x2^1+0x2^0
=> 1x32+0x16+1x8+1x4+1x2+0x1
=> 32+0+8+4+2+0
=> 46
Answer: 46
This is correct since we can verify that 63+-17 = 46
So, there was no overflow.



Related Solutions

Show the decimal integer 44 in 7-bit sign magnitude, one's complement, two's complement and excess-63 respectively...
Show the decimal integer 44 in 7-bit sign magnitude, one's complement, two's complement and excess-63 respectively in the given order, separated by comma.
Show the decimal integer 79 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively...
Show the decimal integer 79 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively in the given order, separated by comma.
Show the decimal integer -126 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively...
Show the decimal integer -126 in 8-bit sign magnitude, one's complement, two's complement and excess-127 respectively in the given order, separated by comma.
Assuming signed two’s complement representation using m=8 bits, add the following numbers using binary addition AND...
Assuming signed two’s complement representation using m=8 bits, add the following numbers using binary addition AND determine the values of the N, Z, V and C flags in response to each calculation. (-128) + (+100) (+5) + (+7) (+5) + (-7) (-5) + (+7) (-5) + (-7) (+120) + (+100) (-120) + (-100) (6A)16+ (E2)16 (A7)16+ (35)16 (80)16+ (80)16
convert +38 and +17 to binary using the signed 2s complement representation and enough digits to...
convert +38 and +17 to binary using the signed 2s complement representation and enough digits to accomaodate the numbers. Then perform the binary equivalent of (-38) and +17
Complete the matrix below (use 4 bits) Signed Integer Signed Magnitude 1’s Complement 2’s Complement Excess-7...
Complete the matrix below (use 4 bits) Signed Integer Signed Magnitude 1’s Complement 2’s Complement Excess-7 5 -3
Complete the matrix below (use 4 bits) Signed Integer Signed Magnitude 1’s Complement 2’s Complement Excess-7...
Complete the matrix below (use 4 bits) Signed Integer Signed Magnitude 1’s Complement 2’s Complement Excess-7 5 -3
Show the decimal integer -143 in 10-bit sign magnitude, one's complement, two's complement and excess-511 respectively...
Show the decimal integer -143 in 10-bit sign magnitude, one's complement, two's complement and excess-511 respectively in the given order
Show decimal values below in two complement binary notation with 6 bits. a) 18 b) -12
Show decimal values below in two complement binary notation with 6 bits. a) 18 b) -12
Show that he gcd of 63 and 40 is 1 and find all integer solutions: 63s...
Show that he gcd of 63 and 40 is 1 and find all integer solutions: 63s + 40t = 1. Use the Euclidean algorithm to find the gcd. Then back solve to find s and t. To get full credit, use the format shown in the post below titled Bezout's Theorem. (See the example where we find the gcd of 18 and 5.) Bézout's theorem says "If  d is the gcd of m and n then we can find integers s...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT