There are three different cases possible when we add two binary numbers which are as follows:
Case 1: Addition of the positive number with a negative number when the positive number has a greater magnitude.
Initially, calculate the 1’s complement of the given negative number. Sum up with the given positive number. If we get the end-around carry 1, it gets added to the LSB.
Example: 1101 and -1001
First, find the 1’s complement of the negative number 1001. So, for finding 1’s complement, change all 0 to 1 and all 1 to 0. The 1’s complement of the number 1001 is 0110.
Now, add both the numbers, i.e., 1101 and 0110;
1101+0110=1 0011
By adding both numbers, we get the end-around carry 1. We add this end around carry to the LSB of 0011.
0011+1=0100
Case 2: Adding a positive value with a negative value in case the negative number has a higher magnitude.
Initially, calculate the 1’s complement of the negative value. Sum it with a positive number. In this case, we did not get the end-around carry. So, take the 1’s complement of the result to get the final result.
Example: 1101 and -1110
First find the 1’s complement of the negative number 1110. So, for finding 1’s complement, we change all 0 to 1, and all 1 to 0. 1’s complement of the number 1110 is 0001.
Now, add both the numbers, i.e., 1101 and 0001;
1101+0001= 1110
Now, find the 1’s complement of the result 1110 that is the final result. So, the 1’s complement of the result 1110 is 0001, and we add a negative sign before the number so that we can identify that it is a negative number.
Case 3: Addition of two negative numbers
Example: -1101 and -1110 in five-bit register
Firstly find the 1’s complement of the negative numbers 01101 and 01110. So, for finding 1’s complement, we change all 0 to 1, and all 1 to 0. 1’s complement of the number 01110 is 10001, and 01101 is 10010.
Now, we add both the complement numbers, i.e., 10001 and 10010;
10001+10010= 1 00011
By adding both numbers, we get the end-around carry 1. We add this end-around carry to the LSB of 00011.
00011+1=00100
Now, find the 1’s complement of the result 00100 that is the final answer. So, the 1’s complement of the result 00100 is 110111, and add a negative sign before the number so that we can identify that it is a negative number.