Solve each of the following 8-bit subtraction
problems using 2’s complement representation:
i. 011111112 - 78 base10
ii. 001100102 - 123 base10
iii. 010010012 - 111 base10
iv. 000001112 - 35 base10
78 = 1001110
so,
01111111 - 01001110 = 00110001
Do the others in like wise, but watch out for negative values.
Answer
To solve each of the 8-bit subtraction problems using 2's complement representation, follow these steps:
i. 01111111 (127 base10) - 78 base10
Step 1: Convert 78 to its 8-bit binary representation:
78 base10 = 01001110
Step 2: Find the 2's complement of the binary representation of 78:
Flip all the bits: 10110001
Add 1: 10110001 + 1 = 10110010
Step 3: Perform binary addition:
01111111 + 10110010 = 00110001
The result is 00110001, which represents -49 in base10.
ii. 00110010 (50 base10) - 123 base10
Step 1: Convert 123 to its 8-bit binary representation:
123 base10 = 01111011
Step 2: Find the 2's complement of the binary representation of 123:
Flip all the bits: 10000100
Add 1: 10000100 + 1 = 10000101
Step 3: Perform binary addition:
00110010 + 10000101 (ignoring the overflow) = 10100111
The result is 10100111, which represents -105 in base10.
iii. 01001001 (73 base10) - 111 base10
Step 1: Convert 111 to its 8-bit binary representation:
111 base10 = 01101111
Step 2: Find the 2's complement of the binary representation of 111:
Flip all the bits: 10010000
Add 1: 10010000 + 1 = 10010001
Step 3: Perform binary addition:
01001001 + 10010001 (ignoring the overflow) = 11011010
The result is 11011010, which represents -46 in base10.
iv. 00000111 (7 base10) - 35 base10
Step 1: Convert 35 to its 8-bit binary representation:
35 base10 = 00100011
Step 2: Find the 2's complement of the binary representation of 35:
Flip all the bits: 11011100
Add 1: 11011100 + 1 = 11011101
Step 3: Perform binary addition:
00000111 + 11011101 (ignoring the overflow) = 11100000
The result is 11100000, which represents -32 in base10.
To solve each of the following 8-bit subtraction problems using 2's complement representation, follow these steps:
Step 1: Convert the decimal numbers to their 8-bit binary representations.
Step 2: Calculate the 2's complement of the second number (subtrahend).
Step 3: Add the first number (minuend) with the 2's complement of the second number.
Step 4: If there is a carry out of the most significant bit (MSB), it means the result is negative. In this case, take the 2's complement of the sum and add a negative sign to the result. Otherwise, the result is positive.
Let's solve each problem step by step:
i. 011111112 - 78 base10
Step 1: Convert 78 to an 8-bit binary number.
78 base10 = 010011102
Step 2: Calculate the 2's complement of 010011102.
The 2's complement is obtained by inverting all the bits and adding 1.
2's complement of 010011102 = 101100002
Step 3: Add 011111112 with 101100002.
01111111
+ 10110000
___________
11101111
Step 4: Since there is no carry out of the most significant bit, the result is positive.
11101111 base2 = -17 base10
ii. 001100102 - 123 base10
Step 1: Convert 123 to an 8-bit binary number.
123 base10 = 011110112
Step 2: Calculate the 2's complement of 011110112.
2's complement of 011110112 = 100001112
Step 3: Add 001100102 with 100001112.
00110010
+ 10000111
___________
10111001
Step 4: Since there is a carry out of the most significant bit, the result is negative.
Take the 2's complement of 10111001 and add a negative sign.
2's complement of 10111001 = 010001112
Result: -49 base10
iii. 010010012 - 111 base10
Step 1: Convert 111 to an 8-bit binary number.
111 base10 = 011011112
Step 2: Calculate the 2's complement of 011011112.
2's complement of 011011112 = 100100012
Step 3: Add 010010012 with 100100012.
01001001
+ 10010001
___________
11011010
Step 4: Since there is a carry out of the most significant bit, the result is negative.
Take the 2's complement of 11011010 and add a negative sign.
2's complement of 11011010 = 001001102
Result: -39 base10
iv. 000001112 - 35 base10
Step 1: Convert 35 to an 8-bit binary number.
35 base10 = 001000112
Step 2: Calculate the 2's complement of 001000112.
2's complement of 001000112 = 111111112
Step 3: Add 000001112 with 111111112.
00000111
+ 11111111
___________
000001110
Step 4: Since there is no carry out of the most significant bit, the result is positive.
00000111 base2 = 7 base10
Therefore, the results are:
i. -17 base10
ii. -49 base10
iii. -39 base10
iv. 7 base10