Question

In: Computer Science

For the following operations: write the operands as 2's complement binary numbers then perform the addition...

For the following operations: write the operands as 2's complement binary numbers then perform the addition or subtraction operation shown. Show all work in binary operating on 8-bit numbers.
7 + 3
7 - 3
3 - 7

Solutions

Expert Solution

1)
Number: 7
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 7 successively by 2 until the quotient is 0
   > 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 111
So, 7 of decimal is 111 in binary
Adding 5 zeros on left hand side of this number to make this of length 8
so, 7 in 2's complement binary is 00000111

Number: 3
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 3 successively by 2 until the quotient is 0
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 11
So, 3 of decimal is 11 in binary
Adding 6 zeros on left hand side of this number to make this of length 8
so, 3 in 2's complement binary is 00000011

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

Verification:
---------------
sum = 00001010
since left most bit is 0, this number is positive
so, we can directly convert this into a decimal value
=> 1010
=> 1x2^3+0x2^2+1x2^1+0x2^0
=> 1x8+0x4+1x2+0x1
=> 8+0+2+0
=> 10
Answer: 10
This is correct since we can verify that 7+3 = 10
So, there was no overflow.

2)
Number: 7
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 7 successively by 2 until the quotient is 0
   > 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 111
So, 7 of decimal is 111 in binary
Adding 5 zeros on left hand side of this number to make this of length 8
so, 7 in 2's complement binary is 00000111

Number: -3
Let's convert this to two's complement binary
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 3 successively by 2 until the quotient is 0
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 11
So, 3 of decimal is 11 in binary
Adding 6 zeros on left hand side of this number to make this of length 8
So, 3 in normal binary is 00000011
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   00000011 is flipped to 11111100
Step 3:. Add 1 to above result
11111100 + 1 = 11111101
so, -3 in 2's complement binary is 11111101

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

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

3)
Number: 3
Let's convert this to two's complement binary
Since this is a positive number. we can directly convert this into binary
Divide 3 successively by 2 until the quotient is 0
   > 3/2 = 1, remainder is 1
   > 1/2 = 0, remainder is 1
Read remainders from the bottom to top as 11
So, 3 of decimal is 11 in binary
Adding 6 zeros on left hand side of this number to make this of length 8
so, 3 in 2's complement binary is 00000011

Number: -7
Let's convert this to two's complement binary
This is negative. so, follow these steps to convert this into a 2's complement binary
Step 1:
Divide 7 successively by 2 until the quotient is 0
   > 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 111
So, 7 of decimal is 111 in binary
Adding 5 zeros on left hand side of this number to make this of length 8
So, 7 in normal binary is 00000111
Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0.
   00000111 is flipped to 11111000
Step 3:. Add 1 to above result
11111000 + 1 = 11111001
so, -7 in 2's complement binary is 11111001

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

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


Related Solutions

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
Problem 5: Perform the subtraction on the following pairs of signed numbers using the 2’s complement...
Problem 5: Perform the subtraction on the following pairs of signed numbers using the 2’s complement system. Express the results as signed binary numbers and as decimal values. Please show all work to fully understand. A. 01001 - 11010 B. 10010 - 10011
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 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.
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 the following hexadecimal representations of 16-bit 2’s complement binary numbers to decimal. a.FCAD b.DEAD c.1111...
Convert the following hexadecimal representations of 16-bit 2’s complement binary numbers to decimal. a.FCAD b.DEAD c.1111 d.8000 e.FACE
Problem: Perform following operations in binary using 8-bit addition/subtraction/multiplication. 1. −80 + 42 2. −99 −...
Problem: Perform following operations in binary using 8-bit addition/subtraction/multiplication. 1. −80 + 42 2. −99 − 20 3. 60 − 70 4. −59 × 3 5. 52×−1
Find the solution of the following operation for binary numbers 11011.111- * 100101.01 using2'complement
Find the solution of the following operation for binary numbers 11011.111- * 100101.01 using2'complement
Represent the following numbers in binary 8-bit representation using singed magnitude, one's complement, two's complement, and...
Represent the following numbers in binary 8-bit representation using singed magnitude, one's complement, two's complement, and excess-127 representations: a) 48 b) -35
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT