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

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...
Assume that we are executing the following code on a 32-bit machine using two’s complement arithmetic...
Assume that we are executing the following code on a 32-bit machine using two’s complement arithmetic for signed integers. Which of the following will be printed when the following code is executed (circle those printed, and show work; e.g., how the values are stored): #include <stdio.h> int main() { char x = 0xF;                // x = ________ char y = -1;                 // y = ________ unsigned char z = 0xFF;      // z = 11111111        if (x<z)     printf("performed unsigned compare,...
Compute the following operations using 8-bits 2’s complement encoded numbers: a. 127-47 b. 47-56 c. 19-120
Compute the following operations using 8-bits 2’s complement encoded numbers: a. 127-47 b. 47-56 c. 19-120
using python without external libaries Using integer arithmetic operators '+' and '-', print all combinations that...
using python without external libaries Using integer arithmetic operators '+' and '-', print all combinations that sum up to 'sum' by inserting the operators between digits in 'number'. example for 'number=123456789' and 'sum = 0' Print the output using the terminal: Output should be exactly like this from 1 - 22 1 : +1+2-34-56+78+9=0 2 : +1-2-34+5+6+7+8+9=0 3 : +1-23-4-56-7+89=0 ... 12 : -1+2+34-5-6-7-8-9=0 13 : -1+23+4+56+7-89=0 14 : -1-2+34+56-78-9=0 ... 22 : -12-34+56+7-8-9=0
Part 1: Solve the operation 75.38-18.62 in binary using two's complement. Use 6 bits for the...
Part 1: Solve the operation 75.38-18.62 in binary using two's complement. Use 6 bits for the fractionary part. Part 2:Convert the result to a decimal, and explain how much is the absolute error obtained in the operation. (Provide Step by Step process of problem solving in each part.)
Using Direct method, calculate the arithmetic mean of the given frequency distribution?
Using Direct method, calculate the arithmetic mean of the given frequency distribution?  xi: 92, 125, 180, 80  fi: 12,    7,     6,    9
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT