# Binary addition

**A reminder about denary addition**

When we add denary numbers e.g. 45 + 71, we put them under each other, like this:

4 5

8 1

We then start on the right of the numbers, by adding the units. 5 + 1 = 6.

Then we do the next column, 4 + 8 = 11.

If any calculation results in 10 or more, we have to 'carry' a number into the next column.

In this case, we have 12, so we carry 1 into the hundreds column and leave 2 in the tens column.

4 5

+ 8 1

1 2 6

We follow exactly the same process with binary addition. It's a little bit strange at first; in denary, we only have to carry a number to the next column when a calculation adds up to more than 9. In binary, we have to carry a number if a calculation is more than 1. And we only use 1s and 0s. Although this will look confusing to start with, after half a dozen sums, you will find it quite straight forward.

We are going to add binary numbers. We will always use bytes for our numbers and display the answer as a byte. We will always use a table to help us line up numbers, until we are confident. It is also useful to note the following in binary:

**0 + 0 = 0****0 + 1 = 1****1 + 0 = 1****1 + 1 = 10 (two in denary)**

**1 + 1 + 1 = 11 (three in denary)**

**1 + 1 + 1 + 1 = 100**

**(four in denary)****Example 1****Add 13 + 13 using binary.**

128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
Denary |

0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 13 |

0 | 0 | 0 | 0_{1} |
1_{1} |
1 | 0_{1} |
1 | 13 |

0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 26 |

We always start on the right hand side of the numbers, with the units.

**1 + 1 = 2.****2 in binary is 10.****We write 0 in the units column and carry 1 to the next column.****In the 2s column, 0 + 0 + 1 = 1 so we can write that down.****In the 4s column, 1 + 1 = 2 = 10 in binary.****We write down 0 and carry 1 to the next column.****In the 8s column, 1 + 1 + 1 = 3 = 11 in binary.****We write down 1 and carry 1 to the next column.****In the 16s column, 0 + 0 + 1 = 1 so we can write that down.****the 32, 64 and 128 columns are all 0 + 0 = 0**

**Our final answer is 0001 1010**

It's always a good idea to check your answer. 0001 1010 = (0 * 128) + (0 * 64) + (0 * 32) + (1 * 16) + (1 * 8) + (0 * 4) + (1 * 2) + (0 * 1)

= 16 + 8 + 2 = 26, which is the correct answer.

**Example 2****Add 15 + 30 using binary.**

128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
Denary number |

0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 15 |

0 | 0 | 0_{1} |
1_{1} |
1_{1} |
1_{1} |
1 | 0 | 30 |

0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 45 |

We always start on the right hand side of the numbers, with the units.

**1 + 0 = 1 so we can write that down.****In the 2s column, 1 + 1 = 2 = 10 in binary.****We write 0 in the 2s column and carry 1 to the 4s column.****In the 4s column, 1 + 1 + 1 = 3 = 11 in binary.****We write down 1 and carry 1 to the next column.****In the 8s column, 1 + 1 + 1 = 3 = 11 in binary.****We write down 1 and carry 1 to the next column.****In the 16s column, 0 + 1 + 1 = 2 = 10 in binary.****We write 0 in the 16s column and carry 1 to the 32s column.****In the 32s column, 0 + 0+ 1 = 1 so we can write that down.****the 64 and 128 columns are all 0 + 0 = 0**

**Our final answer is 0010 1101**

It's always a good idea to check your answer. 0010 1101 = (0 * 128) + (0 * 64) + (1 * 32) + (0 * 16) + (1 * 8) + (1 * 4) + (0 * 2) + (1 * 1)

= 32 + 8 + 4 + 1 = 45, which is the correct answer.

**Example 3****Add 12 + 56 using binary.**

128 |
64 |
32 |
16 |
8 |
4 |
2 |
1 |
Denary number |

0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 12 |

0 | 0 | 1_{1} |
1_{1} |
1 | 0 | 0 | 0 | 56 |

0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 68 |

We always start on the right hand side of the numbers, with the units.

**0 + 0 = 0 so we can write that down.****In the 2s column, 0 + 0 = 0 so we can write that down.In the 4s column, 1 + 0 = 1 so we can write that down.In the 8s column, 1 + 1 = 2 = 10 in binary so we write down 0 and carry 1.In the 16s column, 0 + 1 + 1 = 2 = 10 in binary so we write down 0 and carry 1.In the 32s column, 0 + 1 + 1 = 2 = 10 in binary so we write down 0 and carry 1.In the 64s column, 0 + 0 + 1 = 1 so we can write that down.In the 128s column, 0 + 0 = 0 so we can write that down.**

**Our final answer is 0100 0100**

It's always a good idea to check your answer. 0101 0100 = (0 * 128) + (1 * 64) + (0 * 32) + (0 * 16) + (0 * 8) + (1 * 4) + (0 * 2) + (0 * 1)

= 64 + 4 = 68, which is the correct answer.

In the following questions, convert the numbers into binary and then add them up in binary. Lay out your work in exactly the same way as above. When you have got your answer, don't forget to check it!

**Q1.** **13 + 6Q2. 7 + 3Q3. 14 + 15Q4. 10 + 31Q5. 50 + 50Q6. 31 + 7Q7. 63 + 31Q8. 79 + 79Q9. 100 + 63Q10. 121 + 104Q11. 102 + 31Q12. 130 + 120Q13. 142 + 63Q14. 207 + 7Q15. 230 + 15**

**Extension questionsQ16.** How many bits are the in a byte?

**What's the biggest number you can hold in a byte?**

Q17.

Q17.

**Try adding 150 + 150 using the method above. What happened?**

Q18.

Q18.

**Look up what an 'overflow' is in programming.**

Q19.

Q19.

**Set your own addition problems. Test your friends. Try using two-byte numbers if you want to really test yourself and your friends. They can go to about 65000!**

Q20.

Q20.