-[Craig] In this video, we're looking at the way computers store numbers using binary
and how we convert between denary, our number system, and 8-bit binary.
(uplifting piano jingle)
So how do we convert from a denary number to a binary number?
Well, there are two methods, both are equally valid,
and you just need to use the one you feel most comfortable with.
There is the divide-by-two method,
which makes use of modulus, the remainder of division by two,
and the binary number line method.
Let's take a look at each method in turn.
Okay, so here's the divide-by-two method.
So we're going to start with the number 89
and we're going to progressively divide it by two
and work out what's remaining at each stage.
So we start with 89,
we divide by 2, which gives us 44,
and there is one left over,
so we write a one in the remainder column,
and we continue.
44 divided by 2 is 22 with 0 left over.
22 divided by 2 is 11 with 0 left over.
11 divided by 2 is 5 with 1 left over.
Five divided by two is two with one left over.
Two divided by two is one with zero left over.
And finally, one divided by two is zero with the whole one left over.
To get the binary back, we now simply read the number from bottom to top.
So the number 89 in binary is 1-0-1-1-0-0-1.
Now quite often in the exam,
you'll be asked to represent numbers in eight bits and we only had seven here,
so you can pad any leading numbers with zero.
So in an exam,
you'd write 89 out as 0-1-0-1-1-0-0-1.
Now the chances are you won't use that method in an exam,
so we're not going to dwell on it for too long,
but it's helpful to see nonetheless.
Instead, what you'll probably want to remember is simply to
write out a binary number line as shown here,
and consider whether the number you want to store
is more than or equal to the value in the column heading.
If it is, we write a one and reduce the number by that amount.
So let's see what I mean.
So we want the number 89 and we start on the left with 128.
Well, how many 128 fit into 89?
Well, the answer is zero.
So we write 0 and we've got 89 left over.
How many 64s fit into 89?
Well 1 fits in and we've got 25 left over, so we progress to the next column.
So how many 32s fit into 25?
Well that's 0 with 25 left over.
How many 16s fit into 25?
Well that's one,
and now we have nine left over.
How many eights fit into nine?
Well again, it's one with one left over,
Four doesn't fit into one,
two doesn't fit into one.
And finally, one fits into one once with a zero left over.
And again, you read from left to right, and you've got the binary for 89.
To convert from denary to binary, always use this number line,
and it's worth showing your working in an exam,
and it ensures you're less likely to make a silly mistake.
You can always confirm your answer by simply adding up the columns you've got ones in.
So we have a 64 and a 16 and an 8 and a 1,
which of course is 89, the number we were expecting
To convert from binary to denary, again use a number line
and simply add up the values of the columns that have a one in.
So first, we write out our binary number, in this case 0-1-1-0-0-1-1-0.
And now all we need to do is add together the columns that have ones in.
So a 64 plus a 32 is 96 plus a 4 is 100 plus a 2 is 102.
Therefore, the number 0-1-1-0-0-1-1-0 in binary is the number 102 in denary.
Be careful when answering exam questions
because they may ask you to provide your answer in a certain number of bits.
If you're asked to provide the answer in eight bits as mentioned earlier,
you must ensure you have all eight bits of the number in your line.
Remember, you can pad with leading zeros as you need to.
It's worth knowing that at GCSE,
you're only going to be expected to convert 8-bit binary numbers.
(uplifting piano jingle)