In this article, we will perform a subtraction using 2’s complement. An unsigned binary number does not have a sign bit in the most significant bit (MSB) position. For example, consider 8-bit representation of 38_{10}

38_{10} = 0100100_{2}

= 0. 2^{7} + 0. 2^{6} + 1. 2^{5} + 0. 2^{4} + 0. 2^{3 }+ 1. 2^{2} + 0. 2^{1} + 0. 2^{0}

= 0 + 0 + 32 + 0 + 0 + 4 + 0 + 0

= 34 + 4

= 38_{10}

Now, if we take two’s complement of unsigned binary number then we get signed binary representation of a number which is nothing but negative equivalent the unsigned binary number.

To understand this in an easy way, consider previous example of 38_{10}. Let us convert the number 38_{10} into binary.

38_{10} = 0 0 1 0 0 1 0 0

Take 1’s complement of each binary digit in above number. That is, 0 becomes 1 and 1 becomes 0.

= 1 1 0 1 1 0 1 1

Adding 1 to the 1’s complement of 38_{10} we get two’s complement of the binary number.

```
1 1
1 1 0 1 1 0 1 1
+ 1
__________________
1 1 0 1 1 1 0 0
```

The Most Significant Bit (MSB) has 1 which shows that it is a negative number. The resultant number is -38_{10}

### Subtraction using 2’s Complement of unsigned binary number

Two’s complement of binary number is used for subtraction between unsigned and signed binary numbers.

For example,

*How do we subtract?* -34 – (-45) = -34 + 45 = 11

**Step 1:** Convert +34 in 2’s Complement form.

34 = 0 0 1 0 0 0 1 0

Obtain 1’s complement of 0 0 1 0 0 0 1 0

```
0 0 1 0 0 0 1 0
+ 1
__________________
0 0 1 0 0 0 1 1
```

= -34_{10}

Note: The above step is only performed to obtain the -34 values. There are other methods to obtain negative signed values

**Step 2:** Convert -45 into 2’s complement to find +45.

But we can also do it directly.

45_{0} = 0 0 1 0 1 1 0 1 = 0. 2^{7} + 0. 2^{6} + 1. 2^{5} + 0. 2^{4} + 1. 2^{3}+ 1. 2^{2} + 0. 2^{1} + 1. 2^{0}

= 0 + 0 + 32 + 0 + 8 + 4 + 0 + 1

= 32 + 8 + 4 + 1

= 45

**Step 3:** Add binary value of -34 and 45

```
1 1 0 1 1 1 1 0 = -34
0 0 1 0 1 1 0 1 = +45
____________________
0 0 0 0 1 0 1 1 = 1 1 1 0
```

### Example Problems

*Q 1: Perform the subtraction with the unsigned binary numbers by taking the 2’s complement of the subtrahend.*

Source: Computer System Architecture by Morris Mano

**a) 1 1 0 1 0 – 1 0 0 0 0**

**Solution:**

Given

```
1 1 0 1 0 = + 26
1 0 0 0 0 = + 16
Take 1's complement of 1 0 0 0 0
= 0 1 1 1 1
Add +1 to get 2's complement of + 16
Add the binary value of +26 and -16
1
0 1 1 0 1 0 = +26
0 1 0 0 0 0 = -16
_________________
1 0 1 0 1 0 = +10
```

= 10 is the answer.

**b) 1 1 0 1 0 – 1 1 0 1**

**Solution:**

Given

```
1 1 0 1 0 = +26
0 1 1 0 1 = +13
Take 1's complement of +13 = 0 1 1 0 1
= 1 0 0 1 0
Add 1 to get 2's complement of +13
1 0 0 1 0
+ 1
_____________
1 0 0 1 1
Add binary values of +26 and -13
to get the result.
1
0 1 1 0 1 0 = +26
0 1 0 0 1 1 = -13
_____________
1 0 1 1 0 1 = -13
```

The answer is +13.

**c) 100 – 110000**

**Solution:**

```
0 0 0 0 0 1 0 0 = +4
0 0 1 1 0 0 0 0 = +48
Take 1's complement of 48
= 1 1 0 0 1 1 1 1
Add 1 to get the 2's complement of + 48
1 1 1 1
0 1 1 0 1 1 1 1 = +48
+ 1
_________________
0 1 1 1 0 0 0 0
Add the binary values of +4 and -48
to get the correct answer.
0 0 0 0 0 1 0 0 = +04
1 1 0 1 0 0 0 0 = -48
_____________________
1 1 0 1 0 1 0 0 = -44
```

-44 is the answer.

**d) 1010100 – 1010100**

**Solution:**

```
0 1 0 1 0 1 0 0 = 64 + 16 + 4 = +84
0 1 0 1 0 1 0 0 = 64 + 16 + 4 = +84
Take 1's complement of +84 subtrahend
= 1 0 1 0 1 0 1 1
Add 1 to get the 2's complement
of +84 subtrahend
1
1 0 1 0 1 0 1 1
+ 1
_______________
Add the binary values of +84 and -84
to get the result.
1 1 1 1 1
0 1 0 1 0 1 0 0
1 0 1 0 1 1 0 0
_______________
0 0 0 0 0 0 0 0
```

The answer is zero.

### References

- Mano, M. Morris. 1984.
*Digital Design.*Pearson. - Shjiva, Sajjan G. 1998.
*Introduction to Logic Design.*New York: Marcel Dekker, Inc .