Javatpoint Logo
Javatpoint Logo

Addition and Subtraction using 1's complement

In our previous section, we learned about different complements such as 1's complement, 2's complement, 9's complement, and 10's complement, etc.. In this section, we will learn to perform the arithmetic operations such as addition and subtraction using 1's complement. We can perform addition and subtraction using 1's, 2's, 9's, and 10's complement.

Addition using 1's complement

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

  1. 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.
  2. Now, add both the numbers, i.e., 1101 and 0110;
    1101+0110=1 0011
  3. 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.

Note: The resultant is a negative value.

Example: 1101 and -1110

  1. 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.
  2. Now, add both the numbers, i.e., 1101 and 0001;
    1101+0001= 1110
  3. 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

In this case, first find the 1's complement of both the negative numbers, and then we add both these complement numbers. In this case, we always get the end-around carry, which get added to the LSB, and for getting the final result, we take the 1's complement of the result.

Note: The resultant is a negative value.

Example: -1101 and -1110 in five-bit register

  1. 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.
  2. Now, we add both the complement numbers, i.e., 10001 and 10010;
    10001+10010= 1 00011
  3. 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
  4. 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.

Subtraction using 1's complement

These are the following steps to subtract two binary numbers using 1's complement

  • In the first step, find the 1's complement of the subtrahend.
  • Next, add the complement number with the minuend.
  • If got a carry, add the carry to its LSB. Else take 1's complement of the result which will be negative

Note: The subtrahend value always get subtracted from minuend.

Example 1: 10101 - 00111

We take 1's complement of subtrahend 00111, which comes out 11000. Now, sum them. So,

10101+11000 =1 01101.

In the above result, we get the carry bit 1, so add this to the LSB of a given result, i.e., 01101+1=01110, which is the answer.

Example 2: 10101 - 10111

We take 1's complement of subtrahend 10111, which comes out 01000. Now, add both of the numbers. So,

10101+01000 =11101.

In the above result, we didn't get the carry bit. So calculate the 1's complement of the result, i.e., 00010, which is the negative number and the final answer.






Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA