Main content

## Algebra (all 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

© 2023 Khan AcademyTerms of usePrivacy PolicyCookie Notice

# Converting from decimal to hexadecimal representation

## Want to join the conversation?

- I understand the advantages of the hexadecimal system versus the decimal system, but why are some people so fond of the duodecimal system? What would be the (added) advantage of base-12 if we have a popular base-10 and base-16 system?(20 votes)
- The advantage of base 12 is that 12 has a lot of factors: it is divisible by 2, 3, 4 and 6 (and 1 and 12, but they are less interesting).

Base 10 only has two non-trivial factors: 2 and 5. This means in base 10, the two and five times tables are easy and fraction the 1/2 and 1/5 have nice decimals. It's also easy to tell if a number is divisible by 2 or 5 - you just need to check that the last digit is divisible by 2 or 5 respectively.

If we used base 12, the 2, 3, 4 and 6 times tables would be easy and we would have nice decimals for 1/2, 1/3, 1/4 and 1/6. You could tell if a number were divisible by 2, 3, 4 or 6 by just looking at the final digit.(56 votes)

- Why does the term "hexadecimal" implies bases of 16 but not bases of 6?(8 votes)
- Hex means 6. Dec means 10. "Hexadecimal" contains both of those, so it is 6+10=16.(26 votes)

- Just for clarity, the answer is 7D0 (zero) right? Not the letter "o"?(9 votes)
- At3:35, why is the final solution 7D0 instead of just 7D? Does it make any difference if you write it one way or another?(2 votes)
- I had the same confusion.But notice what happens when you write 7D instead of 7D0:

7D = 7 X 16^1 + 13 X 16^0 = 112 + 13 = 125 in decimal

7D0=7 X 16^2 + 13 X 16^1 + 0 X 16^0=1792 + 208 + 0=2000 in decimal.

This shows that the 0 makes difference.You must be careful.

The key thing to realize here is that the last symbol always corresponds to the number of ones(i.e. the base 16 raised to zero).

You go left, starting from 0 as the power of base and then increment the power by one as you go left.

Hope that helped.(8 votes)

- Do decimals work for bases?(2 votes)
- You mean numbers like 18.25, right? You can represent them in other number systems by using the same principle we use with the "decimal" decimal numbers:

Z_10 = . . . + (10^3×??) + (10^2×??) + (10^1×??) + (10^0×??) + (10^-1×??) + (10^-2×??) + (10^-3×??) + . . .

For example, in the decimal system: 18.25 = (10^1×**1**) + (10^0×**8**) + (10^-1×**2**) + (10^-2×**5**) =**10+8+0.2+0.05**

Imagine we're trying to represent this number in base-12; we would use the following pattern instead:

Z_12 = . . . + (12^3×??) + (12^2×??) + (12^1×??) + (12^0×??) + (12^-1×??) + (12^-2×??) + (12^-3×??) + . . .

As you can see, it also contains the(of 12 in this case), that are responsible for what goes on to the right of the "duo-decimal point" in the number:**negative powers**

Z_12 = (12^1×**1**) + (12^0×**6**) + (12^-1×**3**) =**12+6+3/12**= 18.25

18.25 () = 16.3 (**decimal**)**duodecimal**

Basically, you convert the numberthe decimal point into another system and then you separately convert the number**before**the decimal point. In this case the number**after**the decimal point is 25/100 = 2/10 + 5/100 (**after**) =**decimal**/12 +**X**/144 (**Y**) =**duodecimal****3**/12 +**0**/144 = 0.3 ()**duodecimal**(6 votes)

- Isn't A supposed to be 11 not 10 because of the 10 numbers?(0 votes)
- You would think so, but the ten numbers are 0-9, not 1-10. Since it is 0-9, it wouldn't make sense to skip 10.(8 votes)

- How would I go from hex to dec?(2 votes)
- Say that you would have the code of Hex mentioned above given to you, 7D0. You would take that and multiply the amount of each number by it's position's base powered value and add it together: 7 * 16 ^ 2 + 13 * 16 ^ 1 + 0 * 16 ^ 0 = 2000(0 votes)

- Will any practice exercises be added for this section?(1 vote)
- how to convert binary to hexadecimal?(1 vote)
- when I tried to do the same for 1000(decimal) into hexadecimal but I am getting it wrong can you tell me where I am going wrong?

First I divided 1000/256 and got 3.9

then I did 1000-3(256) and got 232.

So it would end up to 3x235+232

232 is 14.5(16)

so there are 3 256 e 16 and this is where I messed up

instead of getting 8 1s i got zero making my answer 3e0 instead of 3e8.

please explain where the 3 8s came from(1 vote)- The mistake is after 232/16.

You get 14.5

Do 232-14(16) = 8

The 14, not the 14.5 is "e", your 2nd digit. the 0.5 on the 14.5 needs to be converted back to a whole number remainder. This is the 8.

Hope this helps.(1 vote)

## Video transcript

-[Voiceover]Let's now
try to convert a number from the decimal system
to the hexadecimal system. Let's say we want to
convert the number 2,000. This is written in decimal form. Let's say we want to write
it in hexadecimal form. Like always, I encourage
you to pause this video and try to work through it on your own. The key here is to break this down into multiples of powers of 16. Let's just write down
our powers of 16 here. 16 to the zero power is one. 16 to the first power is 16. 16 squared is 256. 16 to the third power is 4,096. We've gotten more than large enough. Let's start decomposing. What's the largest power of 16 that is less than or equal to 2,000? It's going to be 256. How many times does 256 go into 2,000? I'll get a calculator out for that. 2,000 divided by, I want
to figure out how many times 256 goes into it, divided by 256. It goes seven times, plus a little bit. What's going to be left over? 2,000 minus seven times 256 is equal to, you're going to have 208 left over. Let me write that. It's going to be seven times 256. Seven, times 256, plus 208 left over. Now let's see if we can
decompose 208 into powers of 16. What's the largest power of 16 that is less than or equal to this? Well it's just going to be 16. So how many 16s go into 208? 208, I'll just take that, divided by 16. 13, exactly 13. We lucked out. So this is exactly 13 times 16. Let's just write that. This right over here
is exactly 13 times 16. Now, we have broken this
down into powers of... We have broken this down into
multiples of powers of 16. Now we're ready to
write it in hexadecimal. We just have to remind
ourselves about the place value. This right over here, this is
going to be the ones place. Then we're going to have the 16s place. Then we're going to have the 256s place. We know how many 256s we have. We have seven 256s. We have zero ones. And how many 16s do we have? Well we have 13 16s. Well what's the digit for 13? We can just remind
ourselves that we obviously have zero through nine and then we have A is equal to 10, B is equal
to 11, C is equal to 12, D is equal to 13 and of
course E is equal to 14 and F is equal to 15. But we care about 13. We have 13 16s. So we put a D right over here. So the number "7D0" in hexadecimals... Let me write this down,
this is interesting. 2,000 in decimal form
is equal to "7D0" when it is written in hexadecimal form. Hope you found that interesting.