 ### Computer Systems

Units & Data Storage
Systems Architecture
Primary & Secondary Storage
Networks & Topologies
Network Security
Systems Software

Even when a decimal number is converted to binary, we can still perform mathematics on them as if they were decimal numbers. One of the mathematical operations is simple addition, where we can add two numbers and get a result.

However sometimes the result of the answer can be too big for our number of bits, and this is called an overflow.

In this lesson, we’ll learn about:

1. How to add two binary numbers together.
2. What overflow errors are and how to they occur.
Media Attachments:

## 1. How to Add Two Binary Numbers

This is the one piece of maths that you need to be able to do for the exam. You will not have access to a calculator.

Let’s take some simple addition in normal decimal notation. Say we wanted to add the numbers 28 and 46.

Let’s work through this simple addition step-by-step:

So we have a decimal value of 74. This is something I am sure you’re very familiar with.

In order to be able to add two binary numbers together, you need to learn the rules of binary addition. These are:

• 0 + 0 = 0
• 0 + 1 = 1
• 1 + 0 = 1
• 1 + 1 = 10 (0 carry 1)
• 1 + 1 + 1 = 11 (1 carry 1)

Let’s try using this to add two numbers in binary.

### Worked Example 1

Let’s try adding 101 and 101.

Now 101 is the number 5, so 5 + 5 should equal 10.

10 in binary is 1010. Let’s see if knowing the answer means we can work it out correctly.

Just like with the decimal addition, we’ll work through this step-by-step:

Step 1 – Let’s start by looking at the 1’s column.

Step 2 – Now let’s look at the 2’s column.

Step 3 – Let’s now look at the 4’s column.

Step 4 – Finally, we look at the 8’s column.

This gives us a final number of 1010.

Which if we convert to decimal, is 10. The correct answer!

### Worked Example 2

Let’s say we wanted to add 111 and 111.

111 is 7, so 7 + 7 should equal 14, which is 1110 in binary.

Step 2 – Now let’s look at the 2’s column.

Step 3 – Let’s now look at the 4’s column.

Step 4 – Finally, we look at the 8’s column.

This gives us a final number of 1110.

Which if we convert to decimal, is 14. The correct answer!

### Worked Example 3

Say you wanted to add two numbers, 1011 and 1001.

The first thing you do is find the decimal values of these two binary numbers:

In the decimal world, 11 + 9 = 20.

Now all we have to do is convert the decimal number 20 back into binary.

So there you have it! 1011 + 1001 = 10100.

### Further Thought

Which of the two methods of binary addition do you think is better and why?

## 2. Overflow Errors

Let’s assume we want to add two 4-bit binary numbers together – 10001 and 1001 (or 9 and 9 in decimal).

Following the rules we learnt in the previous section, answering this question should go as follows:

Step 1 – Let’s start by looking at the 1’s column.

Step 2 – Now let’s look at the 2’s column.

Step 3 – Let’s now look at the 4’s column.

Step 4 – Finally, we look at the 8’s column…

… and there’s 1 to carry over, but now we have a situation called an OVERFLOW.

The resulting binary number needs more bits to store it than the original two numbers. The actual result of adding 9 + 9 would give us 18, which in binary would look like this:

Do you see how the product of the addition needs an extra bit to store the information? This is called an OVERFLOW ERROR. This means that the number of bits required to store your answer is bigger than the number of bits allocated.

## Lesson Summary

So to summarise what we’ve learnt in this lesson:

• Even when a decimal number is converted to binary, we can still do any mathematics on them as if they were decimal numbers.
• In order to be able to add two binary numbers together, you need to learn the rules of binary addition. These are:
• 0 + 0 = 0
• 0 + 1 = 1
• 1 + 0 = 1
• 1 + 1 = 10 (0 carry 1)
• 1 + 1 + 1 = 11 (1 carry 1)
• If the number of bits required to store the answer is bigger than the number of bits allocated, then this is an overflow error.