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 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)
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.
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.  
Write a C++ program to perform two-4 bit binary number operations including addition and subtraction. The...
Write a C++ program to perform two-4 bit binary number operations including addition and subtraction. The user will type in two-4 bit binary numbers with the selection of one of the operations. Then, the program will calculate the result of the calculation. Display two-4 bit binary numbers and the result from the calculation.
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
Design a 9’s complement of a Binary Coded Decimal
Design a 9’s complement of a Binary Coded Decimal
Add or subtract the following 2’s complement form signed numbers, then convert the entire problem to...
Add or subtract the following 2’s complement form signed numbers, then convert the entire problem to decimal and confirm: 110110 + 111000 001100 – 011100
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT