Hexadecimal Number System
Ever wonder how computers pick the exact color for your screen? They use a special 'secret code' called the hexadecimal number system! It might look strange with its letters, but it’s a super useful way of counting that you can learn right now.

What Is the Hexadecimal Number System?
The hexadecimal number system is a way of counting that uses a base of
The hexadecimal system, or base-16, needs more symbols because it counts in groups of sixteen. It uses the same ten digits we're used to (
So, in hexadecimal (often shortened to just "hex"), the digits are:
It might seem strange to use letters as numbers, but once you get the hang of it, you'll see it's just another way of organizing numbers, one that is incredibly useful for computers.
Why Do We Use Hexadecimal Numbers?
If we have a perfectly good base-10 system, why bother with a complicated base-16 system that uses letters? The answer lies inside our computers. At their most basic level, computers don't think in base-10. They think in binary, which is base-2. Binary only uses two digits:
A computer stores all information—from the words in this lesson to the colors on your screen—as incredibly long strings of zeros and ones, like
The number
- For example, the binary string
is equal to in decimal, which is the digit in hexadecimal. - The long binary number from before,
, can be broken into four groups: . - In hex, this becomes
.
Which one would you rather write down?
- Web Colors: To tell a web browser exactly which shade of blue to show, you use a hex code like
. - Memory Addresses: Computers use hex to label locations in their memory, like
. - Error Codes: When a program crashes, it might show an error code like
that helps developers figure out what went wrong.
The Hexadecimal Digits: 0-9 and A-F
The key to understanding hexadecimal is to get comfortable with its sixteen digits. The first ten are easy, as they are the same as our decimal system. The next six are letters that represent the decimal values from
Here is a table that shows each hexadecimal digit and its decimal equivalent. This is a great chart to keep handy as you're learning!
| Hexadecimal Digit | Decimal Value |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| A | 10 |
| B | 11 |
| C | 12 |
| D | 13 |
| E | 14 |
| F | 15 |
When you're counting in hex, you go up the list. After
How Do You Convert from Hexadecimal to Decimal?
Converting a hexadecimal number to a decimal number is all about understanding place value. In our familiar decimal system, each place represents a power of
Hexadecimal works the exact same way, but the place values are powers of
- The rightmost place is the ones place (
). - The next place to the left is the sixteens place (
). - The next place is the two-hundred-fifty-sixes place (
), and so on.
To convert any hex number to decimal, you follow these steps:
- Write down the hex number and identify the place value for each digit (
, etc., from right to left). - If any digit is a letter (A-F), convert it to its decimal value (
- ). - Multiply each digit's decimal value by its corresponding place value.
- Add all these products together. The sum is your answer in decimal.
Convert the hexadecimal number
Step 1: Identify the digits and their place values.
The digits are
is in the (ones) place. is in the (sixteens) place. is in the (two-hundred-fifty-sixes) place.
Step 2: Convert letter digits to their decimal values.
The digit
Step 3 & 4: Multiply and add.
We multiply each digit's value by its place value and sum the results.
So,
How Do You Convert from Decimal to Hexadecimal?
Going the other way, from decimal to hexadecimal, uses a cool math trick involving repeated division. The goal is to figure out how many groups of
Follow these steps:
- Take your decimal number and divide it by
. - Write down the whole number part of the answer (the quotient) and the remainder. The remainder will be a number from
to . - Convert the remainder to its hexadecimal digit (for example, if the remainder is
, the digit is ). This is your first hex digit (the rightmost one). - Take the quotient from step 2 and divide it by
again. - Repeat this process, writing down the new remainder's hex digit to the left of the previous one.
- Continue until your quotient is
. The hex number is the sequence of remainders you found, read from the bottom up.
Convert the decimal number
We will use repeated division by
Step 1: Divide
The remainder is
Step 2: Divide the quotient (
The remainder is
Step 3: Divide the new quotient (
The remainder is
Step 4: Read the remainders from the bottom up.
Our quotients have reached
So,
A Colorful Application: Hex Codes in Digital Design
One of the most common places you'll encounter hexadecimal numbers is in web design and digital art. Colors on a computer screen are created by mixing different amounts of red, green, and blue light. This is known as the RGB color model.
Each of these three colors (Red, Green, and Blue) is assigned an intensity value from
(minimum intensity) (maximum intensity)
A hex color code is a six-digit hex number, usually starting with a hashtag (
- The first two digits (RR) are for Red.
- The middle two digits (GG) are for Green.
- The last two digits (BB) are for Blue.
What color is represented by the hex code
Step 1: Break the code into its R, G, and B components.
- RR =
- GG =
- BB =
Step 2: Convert each two-digit hex number to its decimal equivalent (from 0-255).
Red:
Green:
Blue:
Step 3: Interpret the result.
The RGB value is
Common Mistakes to Avoid
As you start working with hexadecimal numbers, there are a few common pitfalls to watch out for. Being aware of them can save you a lot of confusion!
- Forgetting Letters are Numbers: The most common mistake is seeing a letter like 'C' and not immediately thinking of it as the number
. When you are converting from hex to decimal, you must substitute the decimal value of the letter before you multiply by the place value. - Place Value Errors: When converting from hex, always remember the place values are powers of
( ), not powers of ( ). It's easy to slip back into the habit of using the decimal system's place values. - Reading Remainders Backwards: When converting from decimal to hex using the division method, the remainders must be read from the bottom up. The last remainder you calculate is the first (leftmost) digit of your hex number. Reading them top-down will give you the wrong answer.
- Mixing Up Conversion Methods: There are two different processes: one for hex-to-decimal (multiplication and addition) and one for decimal-to-hex (repeated division). Don't try to use division to convert from hex to decimal, or multiplication to go from decimal to hex. Keep the two methods separate in your mind.
- Forgetting a Zero Remainder: If you divide by
and get a remainder of , you must write down as that place's hex digit. It's a placeholder, just like in the number , and is very important.
Quick Summary
Here are the most important points to remember about the hexadecimal number system:
- Base-16: The hexadecimal system is a base-16 system.
- 16 Symbols: It uses sixteen unique symbols for its digits:
. - Letter Values: The letters A-F represent the decimal values
- . - Place Values: The place values are powers of
, such as , , , and so on. - Hex to Decimal Conversion: To convert a hex number to decimal, multiply each digit by its place value and then add all the results together.
- Decimal to Hex Conversion: To convert a decimal number to hex, use repeated division by
and read the remainders from the bottom up. - Computer Language: Hexadecimal is used in computing as a human-friendly shorthand for binary code, especially for things like colors, memory addresses, and error codes.
Frequently Asked Questions
Why is it called 'base-16'?
Because it uses 16 unique symbols for its digits (0-9 and A-F). The 'base' of a number system tells you how many symbols it uses. Our regular decimal system is 'base-10' because it uses ten symbols (0-9).
Why does hexadecimal use letters?
We need 16 different symbols, but we only have 10 number digits (0 through 9). To get the other six symbols we need, we use the first six letters of the alphabet, A, B, C, D, E, and F, to represent the numbers 10 through 15.
What comes after the number F in hexadecimal?
Just like 9 is followed by 10 in our decimal system,
Where will I see hexadecimal numbers in real life?
You see them all the time on computers! They are used to define colors on web pages (like #FFD700 for gold), in Wi-Fi passwords, and in error messages your computer might show. They are a shorthand for the computer's own language.
Is it hard to learn hexadecimal?
It might seem strange at first because of the letters, but it's not hard once you understand the two main ideas. You just need to remember the place values are powers of 16 and that A-F stand for 10-15.
Can you do addition and subtraction with hexadecimal numbers?
Yes, you absolutely can! It works very much like regular addition and subtraction, but you have to remember to 'carry over' or 'borrow' groups of 16 instead of groups of 10. It's a bit more advanced, but it follows similar rules.
Why is hexadecimal so important for computers?
Computers work with binary (0s and 1s), which creates very long, unreadable numbers. Since