# Binary Addition and Subtraction with Examples

In this tutorial, we will learn about the binary addition and subtraction with the help of examples. By Saurabh Gupta Last updated : May 10, 2023

## 1) Binary Addition

Since binary numbers consist of only two digits 0 and 1, so their addition is different from decimal addition. **Addition of binary numbers** can be done following certain rules:

A | B | Sum | Carry |
---|---|---|---|

0 | 0 | 0 | 0 |

0 | 1 | 1 | 0 |

1 | 0 | 1 | 0 |

1 | 1 | 0 | 1 |

The above table contains two bits a and b, their sum and carry.

**On adding,**

0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 10 (i.e., sum is 0 and carry is 1)

Let's do some exercise and solution some questions based on binary addition to get more of the topic.

### Example 1: Perform (10)_{2} + (11)_{2}

#### Solution

Using the rules provided above, sum operation can be performed as:

Therefore, **(10) _{2} + (11)_{2} = (101)_{2}**

**Verification:**

We can verify our result by converting the above binary numbers into decimal numbers and then verifying the sum.

Here, **(10) _{2} = (2)_{10}**,

**(11)**and

_{2}= (3)_{2}**(101)**, thus when we will add

_{2}= (5)_{10}**2**and

**3**we get sum as

**5**.

### Example 2: Perform (1)_{2} + (1)_{2} + (1)_{2} + (1)_{2}

#### Solution

Using the rules provided above, sum operation can be performed as:

### Example 3: Perform (110)_{2} + (111)_{2} + (101)_{2}

#### Solution

Using the rules provided above, sum operation can be performed as:

**Verification:**

We can verify our result as **(110) _{2}=(6)_{10}**,

**(111)**,

_{2}=(7)_{10}**(101)**and

_{2}= (5)_{10}**(10010)**. So when we will add

_{2}= (18)_{10}**6 + 7 + 5 =18**, which we are getting as our answer.

## 2) Binary Subtraction

The binary subtraction is performed like decimal subtraction, the rules for binary subtraction are:

A | B | Difference | Borrow |
---|---|---|---|

0 | 0 | 0 | 0 |

0 | 1 | 1 | 1 |

1 | 0 | 1 | 0 |

1 | 1 | 0 | 0 |

### Example 1: Subtract (10)_{2} from (1001)_{2}

#### Solution

In column C_{2}, 1 can't be subtracted from 0 so, we have to borrow 1 from column C_{3}, but C_{3} also has a 0, so 1 must be borrowed from column C_{4}, the 1 borrowed from column C_{4} becomes 10 in column C_{3}, now keeping 1 in column C_{3} bringing the remaining 1 to column C_{2} which becomes 10 in column C_{2} thus 10 – 1= 1 in column C_{2}.

In column C_{3}, 1 – 0 = 1

In column C_{4}, 1 after providing borrow 1 is reduced to 0.

Therefore, **(1001) _{2} – (10)_{2} = (111)_{2}**

### Example 2: Subtract (111.111)_{2} from (1010.01)_{2}

#### Solution

In Column C_{0}, 1 can't be subtracted from 0, so we have to borrow 1 from column C_{1}, which becomes 10 in column C_{0}, thus 10 – 1 = 1,

In column C_{1}, after providing borrow 1 to C_{0}, C_{1} is reduced to 0. Now 1 can't be subtracted from so borrow 1 from C_{2}, but it is also 0, so borrow 1 from C_{3} which is also 0, so borrow 1 from C_{4}, reducing column C_{4} to 0. Now, this 1 borrowed from column C_{4} becomes 10 in column C_{3}, keep 1 in the column C_{3} and bring other 1 to column C_{2}, which makes column C_{2} as 10 now again bring 1 from C_{2} to C_{1}, which reduces C_{2} to 1 and makes C_{1} as 10.

Thus, In Column C_{1}, 10 – 1 = 1

In Column C_{2}, 1 – 1 = 0

In Column C_{3}, 1 – 1 = 0

In Column C_{4}, we now have 1 to be subtracted from 0 which is not possible so we will borrow 1 from Column C_{5}, but Column C_{5} has a 0 so borrow 1 from C_{6} making C_{6} to be 0 and bring it to C_{5} which makes it 10 in C_{5}, keep 1 in C_{5} and bring the other 1 to C_{4} which makes C_{4} as 10 thus

In column C_{4}, 10 – 1 = 1

In column C_{5}, 1 – 1 = 0

In column C_{6}, 0 – 0 = 0

Hence, the result is **(1010.01) _{2} – (111.111)_{2} = (0010.011)_{2}**

Related Tutorials

- Computer Number Systems and Its Types
- Representation of Number Systems
- Decimal to Binary Number System Conversion
- Decimal to Octal Number System Conversion
- Decimal to Hexadecimal Number System Conversion
- Binary to Decimal Number System Conversion
- Binary to Octal Number System Conversion
- Binary to Hexadecimal Number System Conversion
- Octal to Binary, Decimal, and Hexadecimal Number Systems Conversion
- Signed Representation of Binary Numbers
- Floating Point Representation of Binary Numbers
- r's and (r-1)'s Complement of Numbers
- Binary Coded Decimal (BCD Code) and Its Addition
- Error-Detecting Code and Parity
- Excess-3 (XS-3) Code and Gray Code

Comments and Discussions!