If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

# Converting directly from binary to hexadecimal

## Video transcript

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 it as base two and explore the connection between that and the hexadecimal hexadecimal number system which is base 16 and the reason why this is interesting is because 16 is a power of 2 and so we'll see is you can almost view the hexadecimal number system it's almost a condensed representation of the binary number system and this is actually why you will actually we've already talked about the binary system is used extensively in computer science and in even in computer engineering it's what's under it's the underlying things that are happening or is the representation used when we're talking about logic gates and transistors and things like that but if hexxit and but hexadecimal also shows up a lot because it is kind of a condensed representation of base 2 so what do I mean by that so let's write out a arbitrary an arbitrary number in base 2 so let's say I have 1 0 1 1 0 1 1 1 0 so this right over here this right over here is in binary and I can even write in parenthesis so this is a binary representation and I want to convert this to its hexadecimal representation and I encourage you to pause the video and try it out on your own and I'll give you a clue on on how you could think about converting directly from base 2 to base 16 think about which what over here is in the 16s place and what is the 256 place over here and then that might help you convert directly so I'm assuming you've had a go at it and the really fun thing about between converting between base 2 and basic scene 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 it's it's especially easy to go convert between these two bases and the realization that you have to make is well what are the powers which places here are powers of 16 so this right over here that is the ones place so one way to think about it is all of this is going to tell you how many one we have ones twos fours and eights but another way to think about is this is a count of of ones all the way up to a potential of fifteen ones so this can count so this is going to be between zero and and I'm going to write it down actually let me write it down and let me write it down in base 16 it's going to be between 0 and F it's going to be between 0 and 15 so it's kind of a count between of the number of ones I guess you could say then this is the 16s place let me do that in a different color this right over here is the 16s place and you can have between 0 and 15 16 so this is also going to be between 0 and F when you look at this four-digit binary number so 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 and then the next four we could keep going although there's only one place here we could go this right over here is the 256 s place and so this is going to be this next four digits that we only have 1 right over here but 1 2 3 and then the fourth one this is also going to be between 0 and 15 256 is so hopefully that helps you a little bit actually if this was a clue I encourage you to pause the video again see if you can represent this in hexadecimal so let's let's try to work this let's we'll try to work this thing together so how many ones do we have so what number is this these four digits right over here this is 8 plus 4 plus 2 so 8 plus 4 is 12 plus 2 is 14 so this right over here is 14 how do we represent that in hexadecimal well 14 is 1 less than 15 so it's going to be e so 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 all right now how many 16s do we have let's see I have no eight I have a four and I have a two so we're going to have six sixteen so we're going to have six sixteen and then how many 256 is do I have all I only have one 256 one 256 so this number and hexadecimal and now I could write that this is in hexadecimal right over here is 1 6 e 1 6 e and I guess you could recall this 256 e 6 6 6 6 teeny I guess 14 yes if I have to come up with a better a better way of reading these hexadecimal numbers and if you're and if and if you're curious what number is because we didn't have to go through decimal just so that you can comprehend it in the number system that you're used to operating and one that's based off of the number of fingers you have feel free to do so