Hexadecimal
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
We are used to counting in a decimal system.
This is a system where the amount of unique numerals is ten, starting at 0 and going up to 9. To count more than the tenth number (which is 9), we need to use 2 or more of the existing numerals.
In decimal, the digits are
0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
We call this a system with a "base 10".
To reach the number after 9, we need to associate two previous numerals: 0 and 1: 10, 11, ..., 42, ...
Hexadecimal is a "base 16" system, where the digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
| Decimal | Hexadecimal |
|---------:|:-----------|
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 5 |
| 6 | 6 |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| 10 | A |
| 11 | B |
| 12 | C |
| 13 | D |
| 14 | E |
| 15 | F |
If we want to represent 16 in hexadecimal, we need to use two digits: 1 and 0. It's very unintuitive at first, but you get used to it.
| Decimal | Hexadecimal |
|--------:|:------------|
| 16 | 10 |
| 17 | 11 |
| 18 | 12 |
| 19 | 13 |
| 20 | 14 |
| ... | ... |
| 160 | A0 |
| 161 | A1 |
| 176 | B0 |
A to 10, B to 11, C to 12, and so on)Let's take C2:
| digit | power 16 | | | |------:|----------:|--|:----| | C | 12 X 16^1 |= | 192 | | 2 | 2 X 16^0 |= | 2 | | | total |= | 194 |
Let's take FF:
| digit | power 16 | | | |------:|----------:|--|:----| | F | 15 X 16^1 |= | 240 | | F | 15 X 16^0 |= | 15 | | | total |= | 255 |
In regular programming, hexadecimal is most often encountered to encode colors.
For example:
#FF0000 is red.#00FF00 is green.#0000FF is blue.The format is #RRGGBB, where RR, GG, and BB are hexadecimal values for the red, green, and blue channels, respectively.
This is because the hexadecimal color encoding takes two digits to represent each color channel: in the first example, FF is the amount of red in the color, and 00 is the amount of green in the color. FF is equal to 255, so that is equivalent to writing rgb(255, 0, 0).
Some hexadecimal notations add two digits to represent alpha: #RRGGBBAA, where 00 is completely transparent, and FF is completely opaque.
Finally, in some languages, it is accepted to use the #RGB format, omitting the 0 for small numbers.
Don't stop here. Step-by-step tutorials are fun but they only take you so far.
Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…