Main content

## Binary and hexadecimal number systems

# Converting from decimal to binary

## Video transcript

Let's see if we can get some experience converting from a decimal representation to a binary representation. Let's start with the fairly
straightforward example with a fairly low number. Let's see if we can convert the number 13 in decimal to binary. And I encourage you to pause the video, and try to work through
it out on your own. So I'm assuming you had a go at it. So the key here is to see if you can deconstruct the number 13
as the sum of powers of two. And then it becomes very straightforward to represent it in binary. Because in binary, you're
essentially saying, well what powers of two do you
need to make up this number. So let's just write
the powers of two here, just to remind ourselves. And I'll go until we go right above 13. So two to the zero is equal to one, Two to the first is equal to 2. Two squared is equal to four. Two to the third is equal to eight. Two to the fourth is equal to 16. So now, I'm above 13, so I have all the powers of two
that I need to construct 13. So what's the largest power of two, that is less than or equal to 13? Well, 16's too large,
well it would be eight. So I could rewrite 13 as eight plus five. Now five is not a power of two, so I have to keep deconstructing that. What's the largest power of two, that is less than or equal to five? We see it right over here, it's four. So let me rewrite that, it's eight plus, instead of writing five, I'll write four plus one, and then the good thing is
at one as a power of two we already see is the largest power of two that is less than or equal to it is one. This already is a power of two. So I now have rewritten this as the sum of powers of two. Notice this is two to the third power. This is two squared, and this
is two to the zero power. Or I could write it like this. I have 1 eight, clearly. I have 1 four, and I have 1 one. So I can add these two, I
can add these three together. 13 could be considered 1
eight plus 1 four plus 1 one. Why is that helpful? Well now, let's go in to binary mode. And think about what each of
the place values represent. So, this is the ones place,
that's the ones place. And then we can go to the twos place. Every time we go to the left, each place we multiply by two. It's the next power of two. Then we go to the fours
place, fours place. And then we go the eights place, eights. In binary I only have
two digits, zero and one. So I either have zero of a
place or I have one of it. So let's go through it. How many ones do I have? Well I have 1 one, so I write that there. How many twos do I have? Well in this representation
I don't have any twos. I have an eight, I have a four and a one. So I'm gonna put I have 0 twos. How many fours do I have? Well I have 1 four. And how many eights do I have? Well I have 1 eight. So 13, or 13 which is a decimal number. If I were to write it in
binary, is one one zero one.