- [Craig] In this video, we're going to look at how you add together two 8-bit binary integers.
(uplifting piano jingle)
So, before we work through some examples with you, let's just go over the basic rules for binary addition.
So, they're quite simple - a 0 and a 0 in binary equals 0.
A 0 and a 1 equals 1.
A 1 and a 1 can't equal 2 because we don't have a 2 in binary,
so a 1 and a 1 in binary equals 0, and then we carry a 1 to our next column
because 1-0 in binary is the denary number 2.
And finally, 1 plus 1 plus 1 in denary is 3 but we can't have 3, so it's 1, carry a 1.
1-1 in binary is 3 in denary - that's a 1 in the 2 column plus a 1 in the 1 column.
Now, these are the only four rules you're going to need at a GCSE level when adding together two 8-bit binary numbers.
So, let's work through some examples.
So here, we have a binary number line, and we always suggest you write this out in the exam.
You start with a 1 on the far right and then you double each column as you go to the left - 2, 4, 8, etc.
We've shown you the two denary numbers on the right we're going to add together, so we're going to add together 85 and 170.
So, I've sped things along here and written out those two binary numbers.
Now, in the previous video, we showed you how to do that, but here, we're going to focus on adding them together.
So, we're going to start on the right-hand side with the column that has a weighting of 1,
and we just follow the four rules of binary addition we went over at the start of the video.
So, a 1 plus a 0 is a 1,
a 0 plus a 1 is a 1,
a 1 plus a 0 is a 1,
a 0 plus a 1 is a 1,
a 1 plus a 0 is a 1,
a 0 plus a 1 is a 1,
a 1 plus a 0 is a 1,
and a 0 plus a 1 is a 1.
A nice, simple, tidy, easy example to start with.
We add up every column that has a 1 in it, so that's all of them, 128 plus 64 plus 32 and so on,
and we get 255 which, of course, is the original numbers 85 and 170 added together.
Okay, so let's take a look at another example - this time, 43 plus 74.
So, here I am again, and I've written out the two binary numbers, so let's start on the right.
A 1 and a 0 is a 1,
a 1 and a 1 is a 0, and then we carry a 1 to the next column.
It's important to show these carries in the exam - write them underneath.
So, now we have a 0 and a 0 and the carry 1 - well, 0 and 0 and 1 is 1.
1 and 1 is 0, carry the 1.
0, 0 and the carry 1 is 1.
1 and 0 is 1,
0 and 1 is 1,
and 0 and 0 is 0.
Again, you add up the columns that have the 1s in, so that's a 64 plus a 32 plus a 16 plus a 4 and a 1, giving us 117.
Okay, let's take one more example, 59 plus 124.
So again, I've written out their binary equivalents here.
Now, why don't you pause this video now and on a scrap of paper, write down the binary addition
and then unpause the video and see how you did?
So, a 1 and 0 is a 1,
a 1 and 0 is a 1,
a 0 and 1 is a 1,
a 1 and 1 is 0, carry a 1,
a 1, 1 and the carry 1 is 1, carry the 1.
Again, a 1, 1 and a carry 1 is a 1, carry the 1,
A 0, 1 and the carry 1 is 0, carry the 1,
and finally, the 0, 0 and a carry 1 is 1.
So, our binary answer is 1-0-1-1-0-1-1-1, which is 183.
Let's do one last example here - so, we've got the numbers 95 and 222 in denary.
There they are written out under their binary weighting lines.
Again, we start on the right-hand side - we have 1 and 0, it's a 1.
A 1 and 1 is a 0, carry a 1,
A 1, 1 and a carry 1 is 1, carry a 1.
Again, we have a 1, 1 and a carry 1 is a 1, carry a 1.
Another 1, 1 and a carry 1 is 1, carry the 1.
0, 0 plus a carry 1 is just 1,
1 and 1 is 0, carry a 1,
and here, we have a 0, 1 and a carry 1 is 0 and we need to carry an extra 1,
and what's happened here is we've got an overflow.
Our carry 1 has gone beyond the capacity of our current storage line,
and this is something which might crop up in the exam.
The denary numbers 95 plus 222 should equal 317.
But if we read back the number we've actually got, we've got a 1 in the 32 column, a 1 in the 16, an 8, a 4 and a 1,
and that does not equal 317.
You might have spotted the reason for that.
That's because the denary number 95 can be stored in an 8-bit binary weighting line,
and the denary number 222 can be stored in an 8-bit binary weighting line.
But the sum of those two numbers, 317, is too big to be stored in an 8-bit binary weighting line.
The maximum number that can be stored is 255.
We get this overflow and the resulting number is now meaningless.
You would need to add an extra column on the left beyond the 128 with a weighting of 256 to store this number.
But as we say, in your GCSE exams, you'll only be expected to add 8-bit binary numbers.
(uplifting piano jingle)