Man a lot of you
feel that you know something about binary, so I thought this is a
Relatively simple and compact topic that I might be able to make a relatively short video about
I want to start off by just doing a simple addition sum in
the Normal Tens
Counting system that we use just to remind you about things like how to carry a digit from one column
Into the column to the left of it and so on
First thing I probably ought to do right up at the top here
Which is why I've tried to leave myself a bit of space is to remind you. What do these columns mean
in this column is the unit's always it's the ones if you like and
In the tens system the one to the left of it is counting up the number of tens
that you've got and of course this one on the left is counting up the hundreds the more you get into the
Mathematics of this the more you learn that really and more fundamentally
Hundred is 10 to the power
2 10 itself is a ten to the power one call if we have thousands over here
That's the 10 to the power 3 Column so what's this one, well anything to the power 0 is 1
even 2 or 3 or
77 anything to the power 0 is 1
Okay, so those headings. I hope will remind you about what each column actually means
Now let's just draw a line here and do this addition
5 plus 5 is 10, but if you get 10 in any one of these columns
You can't write down 10 the rule is it's every digit in one of these columns can range between 0 and 9
When we come on to binary of course we'll be counting in twos and the rule there is
Every digit you put down must be 0 or 1 but it can't be two
so instead of saying five plus five is ten and writing ten if you recall we put down a note and we carry a 1
You make a little note of it somehow down here, and then what you do is you say well in the tens column
I've got five tens in this certain number up here
Three tens in this one five and three is eight eight in the tens column are but I carried one over from here
So that's a total of nine tens
There's nothing further to carry out from the tens column into the hundreds because it's in range
It's got a nine so all you do is put a 1 there nothing there 1 plus nothing is 1 so the answer is
190 let's do a binary example immediately below this decimal one
So we're going to be in 4-bit binary from here on in down here. So straight away by analogy with what's gone on above
We can say the first column on the left will be 2 to the power zeros
then will be 2 to the power 1
Then we'll have 2 to the power 2 and then we'll have 2 to the power 3
1 2 3 4 bits or if you like you can also make a note to yourself that
2 to the Power 3. This is the 8th
Column
2 squared this is the fourth Column
this is the twos Column and
recalling that anything to the power 0 is 1
This is the ones or the unit's column is going to come on down here
Let's Do the Following Binary Addition 1
0 1 1
plus
0 0 1 1
So this first number we put in here is
11 in decimal notation
The one in the row below it that we're going to add on
No, eight
no fours 1 2 or 1 1 2 + 1 is 3 so what we're doing in binary is we're going to add 11 to
3 and we hope that the binary answer will look like 14 in binary
but
Again, let me emphasize that the business about carrying digits across
Applies with just the same ferocity in binary as it does in decimal
so this is what you do you start off always on the Right-hand Column 1 plus 1 is 2
You want to write down 2 but you're not allowed to it's like saying 5 plus 5 is 10. You can't write 10
You've got to write zero down and carry one just the same here 1 plus 1 is 2 but I have to
zero down and Carry one as A
Memo to say I must remember to add that one in as well now this gets really hairy now
You've got 1 plus 1 Plus 1
Which is 3 now if you're not allowed to write down a 2 as an answer in this column
You're absolutely not allowed to write down 3 so how do you cope with this situation?
you cope with it by saying well the 3 that has a mast itself in this column is actually composed of a 2 plus a
1 in this column so the one left over you write down here
but that 2 now carries across as a carry into the next column on the left and now find myself with 0
0 & 1 well that's easy
That's just 1 in total finally 1 plus 0 dead easy, so that's the end of that addition you end up with an answer
That's got one in the age column. We've got a four. We've got a two 8 + 4 is 12 + 2 is 14
That's the right answer now those of you
Who are desperately keen computer file types will know from doctor heart bleeds?
Why Gangnam Style throat YouTube because it got 2 billion hits the problem with that is it overflows a 32-bit integer?
What does it mean to say you were overflowing an N-bit?
Representation well I can show that very easily just what happens with the biggest
Representation that you can get in 4 bits
Which is an 8 plus a 4 plus a 2 plus a 1 which of course is 15
What happens if you add 1 to that?
Well it overflows
Why because you do 1 plus 1 is 0?
Carry 1 1 plus that 1 is 0 and Carry 1 1 plus 1 is 0 and?
Carry a 1 again 1 plus 1 is 0 and Carry 1
Errr, we've run out of space
We had a carry out as it's called from the fourth Column across into the 5th column from the right
so we had a carry out into a situation a column that didn't exist and
Carries in two columns that exists as we've seen you just I'm up and take account of them
but if you have a carry out into an adjacent column left that doesn't exist that's called an overflow and
You've got to be constantly aware that overflows can occur
It still prompts the question
That if we did want to do negative numbers within a 4-bit constrained
How could we do actually free software is a wonderful place to do that kind of work?