Question

In: Computer Science

7 – For the following operations: • write the operands as 4-bit 2's complement binary numbers,...

7 – For the following operations:

• write the operands as 4-bit 2's complement binary numbers,

• perform the operation shown,

• show all work in binary operating on 4-bit numbers, and

• identify overflow if necessary.

a) 4 + 2

b) 4 – 2

c) 2 – 4

d) 4 + 4

Solutions

Expert Solution

a)
Number: 4
Let's convert this to two's complement binary
4
Since this is a positive number. we can directly convert this into binary
Divide 4 successively by 2 until the quotient 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 100
So, 4 of decimal is 100 in binary
so, 4 in 2's complement binary is 0100

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

Adding 0100 and 0010 in binary
    0100
    0010
---------
 (0)0110
---------
Sum does not produces a carry
So, sum of these numbers in binary is 0110

Verification:
---------------
sum = 0110
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
Converting 110 to decimal
110
=> 1x2^2+1x2^1+0x2^0
=> 1x4+1x2+0x1
=> 4+2+0
=> 6
Answer: 6
This is correct since we can verify that 4+2 = 6
So, there was no overflow.

b)
Number: 4
Let's convert this to two's complement binary
4
Since this is a positive number. we can directly convert this into binary
Divide 4 successively by 2 until the quotient 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 100
So, 4 of decimal is 100 in binary
so, 4 in 2's complement binary is 0100

Number: -2
Let's convert this to two's complement binary
-2
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 2 successively by 2 until the quotient is 0
   > 2/2 = 1, remainder is 0
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 10
So, 2 of decimal is 10 in binary
So, 2 in normal binary is 0010
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   0010 is flipped to 1101
Step 3:. Add 1 to above result
1101 + 1 = 1110
so, -2 in 2's complement binary is 1110

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

Verification:
---------------
sum = 0010
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
Converting 10 to decimal
10
=> 1x2^1+0x2^0
=> 1x2+0x1
=> 2+0
=> 2
Answer: 2
This is correct since we can verify that 4+-2 = 2
So, there was no overflow.

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

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

Adding 0010 and 1100 in binary
    0010
    1100
---------
 (0)1110
---------
Sum does not produces a carry
So, sum of these numbers in binary is 1110

Verification:
---------------
sum = 1110
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.
   1110 is flipped to 0001
II. Add 1 to above result
0001 + 1 = 0010
III. Now convert this result to decimal value
Converting 10 to decimal
10
=> 1x2^1+0x2^0
=> 1x2+0x1
=> 2+0
=> 2
Answer: -2
This is correct since we can verify that 2+-4 = -2
So, there was no overflow.

d)
Number: 4
Let's convert this to two's complement binary
4
Since this is a positive number. we can directly convert this into binary
Divide 4 successively by 2 until the quotient 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 100
So, 4 of decimal is 100 in binary
so, 4 in 2's complement binary is 0100

Number: 4
Let's convert this to two's complement binary
4
Since this is a positive number. we can directly convert this into binary
Divide 4 successively by 2 until the quotient 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 100
So, 4 of decimal is 100 in binary
so, 4 in 2's complement binary is 0100

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

Verification:
---------------
sum = 1000
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.
   1000 is flipped to 0111
II. Add 1 to above result
0111 + 1 = 1000
III. Now convert this result to decimal value
Converting 1000 to decimal
1000
=> 1x2^3+0x2^2+0x2^1+0x2^0
=> 1x8+0x4+0x2+0x1
=> 8+0+0+0
=> 8
Answer: -8
4+4 must be 8
This is not correct since we can verify that 4+4 not equals -8
So, there was an overflow.

Related Solutions

Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal. a.3030...
Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal. a.3030 b.404 c.5050 d.-5050 e.-20000 Show work with steps
Convert each of the following 5-digit 6’s complement base 7 numbers to 9-digit 4’s complement base...
Convert each of the following 5-digit 6’s complement base 7 numbers to 9-digit 4’s complement base 4. Be careful, show all your reasoning/arithmetic, and make no unwarranted assumptions! (a) 50135 (b) 11402
The standard method of representing negative numbers in the binary system is with 2's complement notation....
The standard method of representing negative numbers in the binary system is with 2's complement notation. What are the advantages and disadvantages of using this method to represent negative numbers?
(a) Convert the decimal numbers, 70 and -26 to binary in the signed 2’s complement system....
(a) Convert the decimal numbers, 70 and -26 to binary in the signed 2’s complement system. Make sure there are enough digits in the results to be able to perform arithmetic operations with these two numbers. (b) Perform in the signed 2’s complement system, (+70) + (-26) (c) Perform in the signed 2’s complement system, (-70) - (-26) (d) Perform in the signed 2’s complement system, (+70) + (+26)
1.convert the following numbers from decimal to binary assuming seven-bit twe's complement binary representation: a)49 b)...
1.convert the following numbers from decimal to binary assuming seven-bit twe's complement binary representation: a)49 b) -27 c)0 d) -64 e) -1 f) -2 g) what is the range for this computer as written in binary and in decimal? 2.convert the following numbers from decimal to binary assuming nine-bit twe's complement binary representation: a)51 b) -29 c) -2 d)0 e) -256 f) -1 g ) what is the range for this computer as written in binary and in decimal?
Please show all work: Determine the 2’s complement equivalent of the following numbers in 8-bit format...
Please show all work: Determine the 2’s complement equivalent of the following numbers in 8-bit format (N.B: You must show your work for full credit)! -12 = -9 =
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT