Question

In: Computer Science

1. What is the two’s complement of: 00110101 2. Carry out the following calculation using 8-bit...

1. What is the two’s complement of: 00110101

2. Carry out the following calculation using 8-bit signed arithmetic (convert to 8-bit binary sequences) and use two’s complement for the negative number, give the result as both an 8-bit binary sequence and in base 10: 127 – 74.

3. What does shifting a binary sequence to left by 3 places correspond to (from the arithmetic standpoint)

Solutions

Expert Solution

1)
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
Converting 110101 to decimal
110101
=> 1x2^5+1x2^4+0x2^3+1x2^2+0x2^1+1x2^0
=> 1x32+1x16+0x8+1x4+0x2+1x1
=> 32+16+0+4+0+1
=> 53
Answer: 53

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

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

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

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

3)
by shifting binary sequence left by n bits, it multiplies the number by 2^n
by shifting by 3 bits, it multiples the number by 8.

Related Solutions

Perform the following calculation in a 6-bit two’s complement system. Show your work. Indicate at the...
Perform the following calculation in a 6-bit two’s complement system. Show your work. Indicate at the end if there will be overflow/underflow or not and why. 1810 – 1010
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,...
Find the decimal equivalents for the following 8-bit two’s complement numbers. a. 0010 0100 Decimal Equivalent...
Find the decimal equivalents for the following 8-bit two’s complement numbers. a. 0010 0100 Decimal Equivalent ___________ b. 1010 1001 Decimal Equivalent ___________ c. 1100 0011 Decimal Equivalent ___________ d. 0101 0101 Decimal Equivalent ___________
Binary How is 00001001 (base 2) represented in 8-bit two’s complement notation? Convert 0.3828125 to binary...
Binary How is 00001001 (base 2) represented in 8-bit two’s complement notation? Convert 0.3828125 to binary with 4 bits to the right of the binary point. How is 00110100 (base 2) represented in 8-bit one's complement.  
What is two’s complement representation? What is one’s complement representation?
What is two’s complement representation? What is one’s complement representation? What is sign-magnitude representation? What is unsigned representation? What is BCD?
(6 marks- 3 marks each) The following hexadecimal values are shorthand for 16-bit two’s complement binary...
(6 marks- 3 marks each) The following hexadecimal values are shorthand for 16-bit two’s complement binary numbers. Working purely in hex, negate each and then state whether the result is positive or negative. (a) 5E91 (b) D00F 2.
Solve each of the following problems by translating the values into two’s complement notation (using patterns...
Solve each of the following problems by translating the values into two’s complement notation (using patterns of 5 bits), converting any subtraction problem to an equivalent addition problem, and performing that addition. Check your work by converting your answer to base 10 notation. (Watch out for overflow.) a. 5 + 1 b. 12 – 5 c. 5 – 11 d. 12 + 5 e. 5 – 1
Represent -34 and +67 in the following way: a) 8 bit 1's complement representation.
Represent -34 and +67 in the following way: a) 8 bit 1's complement representation.
Write -127 as 8 bit signed binary number both using 2'complement and sign/magnitude notation.
Write -127 as 8 bit signed binary number both using 2'complement and sign/magnitude notation.
Carry out the following calculation with the correct number of sig figs. (24.324)(3.2122) – 9.3210 Carry...
Carry out the following calculation with the correct number of sig figs. (24.324)(3.2122) – 9.3210 Carry out the following calculation with the correct number of sig figs. (431.00791+52.5441) / 45.3200130
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT