In: Computer Science
All decimal numbers must be converted to signed two’s complement form before working.
Use the least number of digits necessary (only using one sign bit) to represent the largest number in a given problem. The smaller number must be represented with the same number of bits.
If overflow occurs, indicate that with a note.
Show step by step subtraction.
13 - 8
6 - 19
21 - 14
13 - 8
The first number is = 13
The second number is = 8
The binary representation of the first number is = 1101
The binary representation of the second number is = 1000
We need to subtraction the second number and we can perform the addition operation by using the two's complement.
So, the two's complement of the second number is = 1000
Now, we will perform the addition operation as given below:
1101 + 1000 = 1 0101
If the sign of two subtraction operands is the same or the sign of two additional operands is different then the overflow never occurs.
So, there is no overflow.
After ignoring the carry bit, the MSB is 0, so the result is positive.
The final result is: 0101
6 - 19
The first number is = 6
The second number is = 19
The binary representation of the first number is = 00110
The binary representation of the second number is = 10011
We need to subtraction the second number and we can perform the addition operation by using the two's complement.
So, the two's complement of the second number is = 01101
Now, we will perform the addition operation as given below:
00110 + 01101 = 10011
If the sign of two subtraction operands is the same or the sign of two additional operands is different then the overflow never occurs.
The MSB of the result is 1, so the result is negative and in two's complement form. The get the actual number, we need to find the two's complement first.
The final result is: 10011
21 - 14
The first number is = 21
The second number is = 14
The binary representation of the first number is = 10101
The binary representation of the second number is = 01110
We need to subtraction the second number and we can perform the addition operation by using the two's complement.
So, the two's complement of the second number is = 10010
Now, we will perform the addition operation as given below:
10101 + 10010 = 100111
If the sign of two subtraction operands is the same or the sign of two additional operands is different then the overflow never occurs.
So, there is no overflow.
After ignoring the carry bit, the MSB is 0, so the result is positive.
The final result is: 00111