Main content

## Binary and hexadecimal number systems

# Converting directly from binary to hexadecimal

## Video transcript

- [Voiceover] What I would
like to do in this video is explore the connection between
the binary number system which is clearly, or we've already talked about this, is base two. Explore the quotient between
that and the hexadecimal, hexadecimal number
system, which is base 16. The reason why this is interesting is because 16 is a power of two. What we'll see is you could always view the hexadecimal number system. It's almost condensed representation of the binary number system. This is actually why you will actually, we've already talked
about the binary system is used extensively in computer science and in even computer engineering. It's the underlying
things that are happening or it's the representation
used when we talk about logic gates and
transistors and things like that. But hexadecimal also shows up a lot because it's kind of a condensed
representation of base two. What do I mean by that? Let's write out a arbitrary
number in base two. Let's say I have one, zero, one, one, zero, one, one, one, zero. This right over here is in binary and I can even write in parenthesis . This is a binary representation. I want to convert this to
hexadecimal representation. I encourage you to pause the
video and try out in your own. I'll give you a clue
on how you could think about converting directly
from base two to base 16. Think about which one over
here is in the 16s place and what is the 256 place over here. Then that might help you convert directly. Assuming you had a go at it. The really fun thing about
between base two and base 16 is you don't have to, well for any
bases, you really don't have to go through base 10
but these in particular, it's especially easy to go
convert between these two bases. The realization that you have to make is, what are the powers, which
places here are powers of 16? This right over here,
that is the ones place. One way to think about it
is all of these is going to tell you how many ones we have. Ones, twos, fours, and eights, but another way to think
about it is this is a count of ones, all the way up
to a potential of 15 ones. This could count, this is
going to be between zero, and I'm going to write it down. Actually, let me write it down in base 16. It's going to be between zero and F. It's going to be between zero and 15. It's kind of a count between the number of ones, I guess you could say. Then this is the 16s place. I'm going to do that in different color. This right over here is the 16s place. You could have between zero and 15s, 16s. This is also going to
be between zero and F, when you look at this
four digit binary numbers. Once again, this whole
thing right over here is essentially going to tell
you how many 16s you have. This whole thing is going to tell you how many ones you have. Then the next four, we could keep going, although there is only one place here. We could go, this right
over here is the 256s place. This is going to be the next four digits. They really have one right over here, but one, two, three,
and then the fourth one. This is also going to be
between zero and 15, 256s. Hopefully, that helps you a little bit. Actually, if this was
a clue, I encourage you to pause the video again (laughs) and see if you can represent this in hexadecimal. Let's try to work this thing together. How many ones do we have? What number is this? These four digits right over here. This is eight plus four plus two. So eight plus four is 12, plus two is 14. This right over here is 14. How do we represent that in hexadecimal? Well, 14 is one less than
15 so it's going to be E. This is going to be E. This is E. E is our hexadecimal
representation of the number 14 comes right before our
representation of the number 15 F. Alright, now, how many 16s do we have? Let's see, I have no eights. I have a four, and I have a two. We're going to have six 16s. So we're going to have six 16s. Then, how many 256s do I have? I only have one 256. One 256. This number in hexadecimal,
and I could write that. This is in hexadecimal right
over here, is one, six, E. One, six, E. I guess you could call this 256 E, 16 E. I guess 14. I (laughs) finally have to
come up with a better way of reading this hexadecimal number. If you're not curious what
number is this, because you don't have to go through decimal
just so you could comprehend it in the number system that
you're used to operating in. One that's based off from the
number of fingers you have. Feel free to do so.