Hexadecimal

THE-Spellchecker's avatar
Published Apr 2, 2023Updated May 15, 2024
Contribute to Docs

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.

All contributors

Contribute to Docs

Learn more on Codecademy