Hexadecimal is the number system you encounter constantly in computing without necessarily understanding. Colour codes in CSS (#FF5733). Memory addresses in debuggers (0x1A4F2B00). MAC addresses on network hardware (A4:C3:F0:85:AC:2B). Error codes in Windows (0x000000D1). UUID identifiers in databases. If you've worked with any of these and wondered what the letters are doing in a number, this article explains the entire system — including why it exists and what it makes easier.
The Number Systems: A Quick Comparison
Number systems are defined by their base — the number of unique symbols (digits) they use before cycling back to combinations of those symbols.
Decimal (base-10): The system we use daily. Uses 10 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. After 9, the next number is "10" — a new tens column begins.
Binary (base-2): Uses 2 symbols: 0 and 1. After 1, the next number is "10" in binary — which means 2 in decimal. Use our binary calculator to convert between binary and decimal. Binary is the fundamental language of computers because electronic circuits naturally represent two states: on (1) and off (0).
Hexadecimal (base-16): Uses 16 symbols: 0–9 (same as decimal) plus A, B, C, D, E, F (representing values 10–15). After F (15), the next number is "10" in hex — which means 16 in decimal.
Why 16? The Binary Connection
Hexadecimal exists specifically because of its elegant relationship with binary. One hex digit represents exactly 4 binary bits (a "nibble"). Two hex digits represent exactly 8 binary bits (one byte). This mapping makes hex an extremely compact and readable representation of binary data.
The binary number 11010110 written as hex: split into two groups of 4 — 1101 and 0110. 1101 in binary = 13 in decimal = D in hex. 0110 in binary = 6 in decimal = 6 in hex. So 11010110 binary = D6 hex. Two characters instead of eight, with a direct and lossless conversion.
Compare this to converting that same binary number to decimal: 11010110 = 128 + 64 + 0 + 16 + 0 + 4 + 2 + 0 = 214. Three decimal digits, and the conversion is less obvious from inspection. Hexadecimal's advantage for programmers and system software is that it's more compact than binary while preserving a transparent relationship to the underlying bit pattern.
Hex Digits and Their Values
The full hex digit table:
- 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
A two-digit hex number ranges from 00 (decimal 0) to FF (decimal 255). This is exactly the range of values that can be stored in one byte (8 bits: 2⁸ = 256 possible values). This is why a byte of data is always represented as exactly two hex digits — a fact that appears constantly in colour codes, memory addresses, and data encoding.
Converting Hex to Decimal
Each hex digit position represents a power of 16, just as decimal positions represent powers of 10. The rightmost digit represents 16⁰ (ones), the next represents 16¹ (sixteens), the next 16² (256s), and so on.
Convert hex 2F to decimal: (2 × 16) + (F × 1) = 32 + 15 = 47.
Convert hex 1A4 to decimal: (1 × 16²) + (A × 16¹) + (4 × 16⁰) = 256 + 160 + 4 = 420.
Colour Codes in CSS: Hex in Practice
The most widely encountered hexadecimal application for non-programmers is CSS colour codes. The format #RRGGBB specifies the red, green, and blue components of a colour, each as a value from 00 to FF (0 to 255 in decimal).
#FF0000 = red at maximum (255), green at zero, blue at zero = pure red. #00FF00 = pure green. #0000FF = pure blue. #FFFFFF = all three at maximum = white. #000000 = all at zero = black. #FF5733 = red 255, green 87, blue 51 = a warm orange-red.
Colour pickers in design software show both the hex code and the RGB decimal equivalents simultaneously — the two formats are identical representations of the same colour, with hex simply being more compact for typing and copy-paste.
Hexadecimal and Data Storage
Memory addresses in computing are universally expressed in hex. A 32-bit memory address spans from 0x00000000 to 0xFFFFFFFF (eight hex digits = 32 bits), representing addresses for up to 4 GB of memory. A 64-bit address goes to 0xFFFFFFFFFFFFFFFF — far more than current systems use, but the hex notation keeps it manageable.
Understanding that hex and binary representations of storage are directly related (not approximate conversions as with decimal) is part of why the GB vs GiB confusion exists — storage calculated in binary powers (2¹⁰ = 1,024) versus decimal powers (10³ = 1,000) produces different numbers for the same physical capacity. Our data storage converter handles all conversions between binary and decimal storage units.
The Mozilla Developer Network's documentation on hexadecimal colour notation provides additional detail on CSS colour formats including 3-digit shorthand and alpha channel extensions for web developers needing deeper reference.
