Base 16: Hexadecimal Numbers

Before this, knowBase 2: Binary Numbers

Interactive · 2 questions

Hexadecimal

Hexadecimal is regarded as base-16.16. Each place value in the number is some power of 16.16. The hexadecimal values are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F0,\,1,\,2,\,3,\,4,\,5,\,6,\,7,\,8,\,9,\,A,\,B,\,C,\,D,\,E,\,F The letters AA through FF represent 1010 through 15,15, respectively.

From Decimal to Hexadecimal

Get ready, this method can be a pain to use. Just like with ternary, we want to focus on the remainder.

Let's work through an example to see how it's done. Let's convert 4242 to hexadecimal.

The first step is to divide our number by 16,16, taking the remainder.

42/16 = 2 r10

We get a remainder of 10.10. Remember that hexadecimal uses the letter AA to represent this. So the "ones place" of our hexadecimal number is AA.

Next, we take the non remainder portion, 22, and divide it again by 16.16.

42/16 = 2 r10
2/16 = 0 r2

We get 00 as our non remainder part so we know we're done. The remainder is 22 so this will be the "tens place" of our hexadecimal number. 4210=2A1642_{10}=2A_{16}

From Hexadecimal to Decimal

Just like with binary and ternary, to get to decimal you want to take the sum of each digit multiplied by the powers of the base you're in. Since we're in base-16,16, we multiply by powers of 16.16.

Let's convert 1C21C2 to a decimal number. Starting with 2,2, multiply by 1616 to the zero power, then CC gets multiplied by 1616 to the first power, and 11 gets multiplied by 1616 to the second power. Remember that CC represents the number 12.12. 1C2=(1⋅162)+(C⋅161)+(2⋅160)=(1⋅162)+(12⋅161)+(2⋅160)=(1⋅256)+(12⋅16)+(2⋅1)=256+192+2=450\begin{align} &1C2\\ &=(1\cdot16^2)+(C\cdot16^1)+(2\cdot16^0)\\ &=(1\cdot16^2)+(\color{red}{12}\cdot16^1)+(2\cdot16^0)\\ &=(1\cdot256)+(12\cdot16)+(2\cdot1)\\ &=256+192+2\\ &=450 \end{align}

So, 1C216=450101C2_{16}=450_{10}

Practice

Try some on your own!

What is 16210162_{10} in base-16?

Choose one answer

Interactive · 2 questions

How many numbers can be represented in Hexadecimal?

The standard way of writing numbers, base 10,10, is where we use the digits 0,1,2,3,4,5,6,7,8,0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.9. However, using base 1616 gives us more digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.F. Thus we'd think that if we limit the number of digits we can use, we'd be able to make more numbers in base 1616 than in base 10.10. This intuition is actually helpful, as the claim I made is true.

If we only have 33 digits, we can make less numbers in base 1010 than in base 16,16, because we have more options for each digit. This is true no matter how many digits we allow ourselves to use. It lets us get more information out of fewer digits; that is, it takes less writing or typing to represent bigger numbers.

Now we can work to answer the question of how many different numbers we can make in a given base if we limit the number of digits. We'll answer this question for base 10,10, and then for base 16.16. We start with base 1010 since it's more familiar to most people. For that we turn to the following diagram to guide us:

Pick one option for each digit: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9; for a three-digit number we do this three times

Suppose the number of digits we are allowing is d.d. In the above picture we pick three digits so d=3.d = 3. Then to count how many numbers we can make, we count how many options there are for each digit, and multiply them together. To pick the first digit, we can use 0,1,2,3,4,5,6,7,8,0, 1, 2, 3, 4, 5, 6, 7, 8, or 9,9, giving 1010 possible options. We allow 00 to be the first digit because then we technically have a number with less than dd digits, which is OK; we just can't use more than dd digits.

In the same way, we can pick one of these same digits for the second digit, and then again for the third. This means we have 1010 choices for each digit, and then multiply these numbers together.

10×10×10=100010 \times 10 \times 10 = 1000

If we use no more than 33 digits, we can make 10001000 different numbers in base 10.10. You might realize these are the first 10001000 whole numbers: 0,1,2,...,999!0, 1, 2, ..., 999!

How many numbers can we make in base 1010 with no more than 55 digits?

Choose one answer

Read · 1 min

The digits in hexadecimal (or base 1616) start with 0,1,2,3,4,5,6,7,8,90,1,2,3,4,5,6,7,8,9 (just like in base 1010). The remaining base-1616 digits are A,B,C,D,E,F,A,B,C,D,E,F, corresponding in order to the remaining base-1010 numbers less than 1616 (namely 10,11,12,13,14,1510,11,12,13,14,15).

Read · 1 min

Hexadecimal (aka base-1616) numbers have 22 properties:

  1. Each place numeral is in the set {0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f},\{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f\}, with a−fa-f representing the decimal values 10−15.10-15.
  2. Each place value is equivalent to (number×16place\text{number} \times 16^{place}).

To get the decimal equivalent add the place values.

E.g. The decimal equivalent of 9af29af2 is:

=(9×163)+(10×162)+(15×161)+(2×160)= (9 \times 16^{3}) + (10 \times 16^{2}) + (15 \times 16^{1}) + (2 \times 16^{0})

=(9×4096)+(10×256)+(15×16)+(2×1)= (9 \times 4096) + (10 \times 256) + (15 \times 16) + (2 \times 1)

=36864+2560+240+2= 36864 + 2560 + 240 + 2

=39,666= 39,666

Video

(Video) Hexadecimal

by Carl Herold

Here's a video by Carl Herold showing you how to convert from hexadecimal to base-1010 and base-22.

Summary\large{\text{Summary}}

Here's a video by Carl Herold showing you how to convert from hexadecimal to base-1010 and base-22. This isn't a terribly complicated process but it does require more calculations than the previous sections. What the video doesn't explain is how to convert from base-1010 to base-16.16.

It's pretty simple so I'll show an example. Take a number you want to convert. Let's say it's 145145. First divide the number by 16.16. 14516=9.0625\frac{145}{16}=9.0625 Now take the remainder (0.06250.0625) and multiply it by 16,16, rounding up if necessary. This will become the 11's place. 16×0.0625=116\times0.0625=1 So the 11's place is actually 1.1. Now take the number before the remainder (9).(9). Since it's less than 1616 we know that it's the digit for the 1010s place and we can stop. So the base-1616 version of 145145 is 91.\boxed{91}.

Test Yourself: Convert 30353035 to base-16.16.

Choose one answer

Type a concept, like “slope” or “photosynthesis”.

↑ ↓ to choose · Enter to openSearch explanations and problems