Addition and Subtraction using 2's complementIn our previous section, we learned how we could perform arithmetic operations such as addition and subtraction using 1's complement. In this section, we will learn to perform these operations using 2's complement. Addition using 2's complementThere are three different cases possible when we add two binary numbers using 2's complement, which is as follows: Case 1: Addition of the positive number with a negative number when the positive number has a greater magnitude. Initially find the 2's complement of the given negative number. Sum up with the given positive number. If we get the end-around carry 1 then the number will be a positive number and the carry bit will be discarded and remaining bits are the final result. Example: 1101 and -1001
Case 2: Adding of the positive value with a negative value when the negative number has a higher magnitude. Initially, add a positive value with the 2's complement value of the negative number. Here, no end-around carry is found. So, we take the 2's complement of the result to get the final result. Note: The resultant is a negative value.Example: 1101 and -1110
Case 3: Addition of two negative numbers In this case, first, find the 2's complement of both the negative numbers, and then we will add both these complement numbers. In this case, we will always get the end-around carry, which will be added to the LSB, and forgetting the final result, we will take the2's complement of the result. Note: The resultant is a negative value.Example: -1101 and -1110 in five-bit register
Subtraction using 2's complementThese are the following steps to subtract two binary numbers using 2's complement
Example 1: 10101 - 00111 We take 2's complement of subtrahend 00111, which is 11001. Now, sum them. So, 10101+11001 =1 01110. In the above result, we get the carry bit 1. So we discard this carry bit and remaining is the final result and a positive number. Example 2: 10101 - 10111 We take 2's complement of subtrahend 10111, which comes out 01001. Now, we add both of the numbers. So, 10101+01001 =11110. In the above result, we didn't get the carry bit. So calculate the 2's complement of the result, i.e., 00010. It is the negative number and the final answer.
Next TopicBoolean algebra
|