Bits of Bytes.co

IGCSE / GCSE Computer Science

  • Home
  • 1 - Theory of Computer Science
  • 2 - Practical Problem Solving and Programming
  • Pre-Release Material
    • 2018 June >
      • 22 >
        • 22 - Cow Task
        • 22 - Task 1
        • 22 - Task 2
        • 22 - Task 3
  • 1 - Computer Systems (2023)
Picture
MENU
  • Home
  • 1 - Theory of Computer Science
  • 2 - Practical Problem Solving and Programming
  • Pre-Release Material
    • 2018 June >
      • 22 >
        • 22 - Cow Task
        • 22 - Task 1
        • 22 - Task 2
        • 22 - Task 3
  • 1 - Computer Systems (2023)
1 -1. Computer Systems /   Binary Addition

Binary Addition


Before you attempt to follow this page, please make sure that you have read through and understood the binary introduction page here.
Adding Binary Numbers
Human beings are comfortable with the idea of performing addition with Denary numbers e.g. 4 + 5 = 9

It is equally possible to add Binary numbers e.g. 0100 + 0101 = 1001

Once you are comfortable with the steps involved with adding binary numbers you might even find it easier than adding denary numbers!

How to add Binary Numbers

To add binary numbers you need to first of all remember 4 key rules these are:

Rule 1 = 0 + 0 = 0
Rule 2 = 1 + 0 = 1
Rule 3 = 1 + 1 = 10 (0 below & carry the 1)
Rule 4 = 1 + 1 + 1 = 11 (1 below & carry the second 1)

This may initially be confusing so lets try to put it into a different context with an example.

Lets say that we have been asked to add two simple binary numbers: 10 + 11 (2 + 3).

Worked Example 1


​Step 1 - Place the first binary number on top of the second binary number in a table that looks something like this:
Picture
​Step 2 - Start working with the numbers in the right most column.  In this example we can see that we must add 0 and 1.  Looking at our rules above we can see that 0 + 1 = 1 and therefor we should place a 1 in the answer column.
Picture

​Step 3 - Now move to the next column to the left. In this example you can see that we have 1 + 1.  According to rule 3, 1 + 1 = 10 (2 in binary).  To apply this result we will place the0 in the answer column and then carry the 1 over to the next column to the left.
Picture
​Step 4 - Finally, move to the next column to the left. In this example all we have is the carried over 1.  There is nothing for us to add this 1 with so we simply place it in the answer column. Here we can see that we are left with the answer 101.
Picture

In this example we ended with the binary number 101 which converts into 5.  2 + 3 = 5 so we can confirm that  our addition worked, Yay!.

The same process applies for larger numbers. The only thing omitted from the previous example was the use of rule 4. Lets take a look at slightly larger numbers that will require us to use rule 4.

Worked Example 2


​Step 1 - Place the first binary number on top of the second binary number in a table that looks something like this:
Picture
​Step 2 - Now move to the next column to the left. In this example you can see that we have 1 + 1.  According to rule 3, 1 + 1 = 10 (2 in binary).  To apply this result we will place the 0 in the answer column and then carry the 1 over to the next column to the left.
Picture

​Step 3 - Now move to the next column to the left. In this column we now actually have 3 numbers to add due to the carried over 1.  We have to add 1 + 0 + 1.  The 0 will not really affect this so we essentially have to add 1 + 1.  According to Rule 3 we should place a 0 in the answer column and carry a 1 over to the next column.
Picture
​Step 4 - Moving on to the next column you can see that we now have 1 + 1 + 1 to deal with. According to rule 4 1 + 1 + 1 = 11 (3 in binary).  When faced with this we should place a 1 in the answer column and carry a 1 over to the next column.
Picture

​Step 5 - Moving on to the next column you can see that we now have 1 + 1 + 0 to deal with when you include the carried 1. Again this essentially equates to 1 + 1 which according to rule 2 means that we will need to place a 0 in the answer column and carry over a 1.
Picture
​Step 6 - Finally, move to the next column to the left. In this example all we have is the carried over 1.  There is nothing for us to add this 1 with so we simply place it in the answer column. Here we can see that we are left with the answer 10100.
Picture

As long as you follow these 4 rules and work methodically through each column of the addition then you will be able to add together any binary numbers.

The CAIE IGCSE specification specifies that the largest numbers that you will need to add together is two 8 bit binary numbers e.g.

​10110000 + 01001010

Binary Addition with Overflow


Calculations such as the addition of binary numbers are performed in registers of a limited size.  A register may have a capacity of 8 bits which means that it has the capability of holding 8 bits.

The size of a register will have a crucial impact on the success of an addition.  If you are using an 8 bit register, the largest number that it is going to be able to store is 255. This is achieved when all digits are set to 1.  

The problem?
What would occur if you attempted to add two 8 bit binary numbers where the result would be larger than 255?

Lets attempt to add 200 in binary with 178 as an example.

11001000 + 10110010 = ?
Carried 1s
1
Value
1
1
O
O
O
O
O
O
+
Value
1
O
1
1
O
O
1
O
Result
1
O
1
1
1
O
O
1
O
As you can see from the working out above 11001000 + 10110010 results in a 9 bit binary number - 101110010.

The problem is that we were only able to store the result in an 8 bit register.  When this happens it is known as an OVERFLOW error as the Most Significant Bit (MSB) is left out.  This will result in an incorrect number being stored in the register. 

In this case, the result of the addition would be 01110010 (incorrect) rather than 101110010 (Correct).



Est. 2015 - Copyright © 2020