Hexadecimal
Hexadecimal (hex, hex numbers, or base-16) is a number system that uses a base of 16 as opposed to the standard decimal system, which is base 10. When representing a number, both number systems share the first ten digits, 0-9. However, for hexadecimal, the remaining digits 10-15 are represented by the letters A-F (not case sensitive)
| Decimal | Hex |
|---|---|
| 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 |
Power Of 2
Hexadecimal, as well as binary (base 2) and octal (base 8), have bases that are powers of two, making it easy to convert between one another.
Syntax
A hexadecimal number is prefixed with 0x in many computer languages to identify it as a base 16 number.
Hex Colors
Hex numbers are often used to represent colors (hex colors) and are specified in the following way: #RRGGBB(red, green, and blue). One example of a hex color is #0000FF which represents the color blue. This is because red and green are set to their lowest value, 00, and blue is set to its highest value, FF.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn General on Codecademy
- Start your programming journey with an introduction to the world of code and basic concepts.
- Includes 5 Courses
- With Certificate
- Beginner Friendly.4 hours
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours