Main content

### Course: Algebra (all content) > Unit 1

Lesson 14: Binary and hexadecimal number systems- Introduction to number systems and binary
- Hexadecimal number system
- Converting from decimal to binary
- Converting larger number from decimal to binary
- Converting from decimal to hexadecimal representation
- Adding in binary
- Multiplying in binary
- Converting directly from binary to hexadecimal

© 2024 Khan AcademyTerms of usePrivacy PolicyCookie Notice

# Hexadecimal number system

The hexadecimal number system is a way of counting that uses 16 different symbols instead of just the ten we're used to. It uses the numbers 0-9 like we do, but it also uses the letters A-F to represent the numbers 10-15. This system is useful in computer science because it can represent large numbers in a shorter, more compact way.

## Want to join the conversation?

- i get the the binary base is useful because electricity can only be on or off, so there are only 2 options, but what about the 16 base? is it really used only because it takes less space? there must be other reasons...(20 votes)
- If it was just to save space we would use a higher base than 16. Base-16 is a convenient way for humans to "see" binary as we would only need to learn 16 different patterns.
`0 - 0000 | 8 - 1000`

1 - 0001 | 9 - 1001

2 -0010 | A - 1010

3 - 0011 | B - 1011

4 - 0100 | C - 1100

5 - 0101 | D - 1101

6 - 0110 | E - 1110

7 - 0111 | F - 1111

If we know what pattern goes with what number/letter we can convert a large Binary number to Hexadecimal for ease of use.

Example:

If we split the Hexadecimal 6F28A to look like this 6 | F | 2 | 8 | A

We can see the patterns in 01101111001010001010 which split up look like

0110 | 1111 | 0010 | 1000 | 1010

Here is a tool to play with http://www.binaryhexconverter.com/hex-to-binary-converter(50 votes)

- Base-11 has 11 symbols (0 → 9 and A), base-12 has 12 symbols (0 → 9, A and B). They have
**letters**! I wonder when these number systems were invented. Middle Ages? Early modern period?(9 votes)- You can get all the way up to base 62 using capital letters, lowercase letters, and numbers as digits.(4 votes)

- How does hexadecimal work in other languages? A,B,...F are all part of the English language, so what about Arabic, or Mandarin? Do they use English letters?(8 votes)
- Not sure I got this one correct stated on the video: AF3 Base-16/Hexadecimal

10*10+15+3 = 118

Solved by A^2 (Tens) + F fifteens + 3 ones = 10*10+15+3=118 Does this look correct?(1 vote)- If you want to convert AF3 from hexadecimal system to the decimal one, the result will be: AF3 (in 16-base) = 10*16^2 + 15*16^1 + 3*16^0 = 2803 (in 10-base).

Don't mistake the base!(17 votes)

- For really high base systems, what symbols do you use if there are no more letters left?(6 votes)
- Is FF=255? If so then that is why they use it for color coding because the intensity is from 0-255(or FF)(4 votes)
- Yes. 255 just represents 2 bytes - the binary number 1111 1111 or the hexadecimal number FF.(4 votes)

- What happens with higher bases when you run out of letters(3 votes)
- Since we are arbitrarily constructing these systems in a cultural context that is already decimal based (with some applications of binary and hexadecimal), we must do as Sandeep mentioned -- that is, apply other symbols to provide a convention for use. However, there are cultures from antiquity (and currently to a lesser extent) whose number systems were base-60, base-12, or base-20. These cultures had their own system of writing, which means they had the symbols such as lines, small dots, reeds, large dots, and others to represent these amounts.(4 votes)

- FF is 255 and I'm a fourth grader doing this stuff. Seriously I'm a fourth grader.(0 votes)
- It doesn't matter how old you are, the happiness of knowing even a tiny bit about the universe is wonderful!(23 votes)

- What's the highest base number system that's used for any practical purpose?(2 votes)
- This is the highest complete unit, but it is not exactly the same as a base system. We still write the amounts of degrees for the angle measures in decimal numerals, and we rarely* keep track of the number of full rotations since trigonometric functions are cyclical (i.e., the sine of 360 degrees is equal to the sine of 1080 degrees). This better resembles a modular system (where we start over after we reach the "full amount").

*The primary application I can think of where the number of rotations would matter is in physics with a rotational motion of an object where a full rotation could translate into linear distance as with a wheel or where a full rotation has used or produced a certain amount of joules (energy through work).(4 votes)

- hex means 6 but why we using 16 in hexadecimal system?(3 votes)
- The relevant Ancient Greek and Latin numbers are (GRC–LA–EN):

ἕξ*héx*– sex – six

δέκα*déka*– decem – ten

ἑκκαίδεκα*hekkaídeka*("six and ten") – sēdecim ( "six-ten") – sixteen

The word*hexadecimal*is a mixture of the Greek*hexa-*prefix and the Latin-based*-decimal*suffix (related to*decimus*, "tenth").

In this way, one can think of*hexadecimal*as*hexa-*("six") +*-decim-*("ten") +*-al*.

Please see the Wikipedia article 'Hexadecimal' for more information.(2 votes)

## Video transcript

- [Voiceover] We're all
familiar with the base 10 number system, were
often called the decimal number system, where we have 10 digits Zero, one, two, three, four,
five, six, seven, eight, nine. Now, we started to see that we can have alternate number system. We can have a base two number system, or it's the binary number system, where instead of 10 digits
you only have two digits. Each place, instead of being a power of ten is going to be a power of two. Now you can imagine that
we can keep extending this. We can extend to base three,
four, five, six, seven, eight, nine, or we could even go above 10. What I want to show you
in this video is a fairly, heavily used number system
that is larger than, or that has more digits than
base 10, and that base is 16. Base 16, often called the hexadecimal. Hexadecimal number system. As you can imagine, instead of only having 10 digits, it is going to have 16. What are those digits going to be? As we'll see, instead of
the place is being powers of two or powers of ten,
there will be powers of 16. Let's see, we can reuse
the existing 10 digits from the decimal number system. We can reuse zero, one, two, three, four, five, six, seven, eight, nine, but then we're going to need
to have six more digits. The convention is to use
the first six letters. A, B, C, D, E, and F. You might say this is crazy. These are letters, not numbers,
but remember these are just arbitrary squiggles of
ink on a piece of paper. These are just arbitrary symbols that we're grown to associate with things. You're grown to associate
this symbol right over here with eight thing, with
the word eight which you associate with when you
see that many objects. If you're thinking in hexadecimal,
this isn't the letter A that makes you want to
say "ah", or the letter B that makes you want to say "bababababa". This is, literally, this represents if you had 10 things laying around. You would say, "I have
A things over there." If you have 11, you'd say,
"I have B things over there." 12, C things. 13, instead of saying,
"I have 13 things there", "I have D things there." Instead of saying, "I have 14", you could say, "I can
have E things there." Instead of saying, "I have 15", you could say, "I have F things there." Now, how does that help? Well, let's see if we can represent the same number 231, or 231 in decimal. If we can represent that
same number in hexadecimal. What I'll do is I'll give
you what the number is, and then I'll show you how we convert it. I'll show you the place value, and I'll show you how we convert it. 231 in hexadecimal. 231 in hexadecimal is the number E seven. E seven. Once again, you're
like, "This looks crazy. "This is like I'm playing
like battleship or something." What's E seven? This is a number and I would say yes. This is a number. Now remember, base 16. What are these place values represent? This first place represents
16 to the zero power or still represents the ones place. This is the ones place. This is seven ones. Now, what is this place here represents? Well, in base 10, that
was 10 to the first power. In base two, that was
two to the first power. On base 16, this is going to be, I'll leave those there, in base 16, this is going
to be 16 to the first power. This is literally, well let me write out the word, this is literally sixteens. This is E sixteens plus seven ones. Let me write that down. This is E sixteens plus seven ones. That's what this number represents. Now, if we want to start rewriting this or re-conceptualizing it in our decimal number system, what is E sixteens? Well, the E if we think
in decimal, E is 14. E is 14. This is really, we can
really think of this if you want to think them decimals. This is 14 sixteens. It's 14 sixteens. Well, that's just the
same thing as 14 times 16. 14 times 16 is equal to 224. Maybe I should do that in same color. This thing right over
here is going to be 224. 14 sixteens, 14 times 16
is 224 plus seven ones. Well, 224 plus 7 is
going to be give you 231. Hopefully, you can appreciate it. You can represent the same quantity in any of these different number systems. In any number that you
can represent in decimal, you can also represent
that number in binary, or in hexadecimal, or in
base three, or in base 60, or in base 31, whatever you want to do. You might have noticed the pattern. The more symbols that we have, so in base 16, you have 16 symbols, the less place values we need to represent the same quantity. One way to think about it is each of the places are
containing more information. This is one of 16 characters. While this over here is
only one of two characters. This is one of ten characters. The more symbols that
you have, the more digits that you could put in each
place, the less places that you need to represent
a given quantity. Another way to think about it
is when you have a high base, like base 16, as you take
powers of 16, the next place right over here would be 16 squared, which, of course, is two
hundred and, wait a minute, 256. You're clearly going to be able
to represent bigger numbers faster, I guess you could
say, or with less digits. It's just an interesting thing to observe. But hopefully, you're
going to kick out of, as much of a kick out of base 16 as I do, and it's actually useful. This actually is used if
you look at most web pages. If you look at the actual code for there, or I guess you could say the
formatting line, the HTML for the webpage, when they specify colors, they tend to specify in hexadecimal. That's because they're specifying
the colors, the intensity of the red, the green, or the
blue, between zero and 255. Two digits of hexadecimal
are perfect for that, because if you think
about it, what is F F? What would this be if you
rewrite it in the decimal number system, and I encourage you
after this video is done, I encourage you to do that to
figure that out on your own. If you really want to do something fun, let me give you another one. Try to figure out what A F three is. Again, this isn't very specialized. I just wanted to give you another interesting thing to work on.