1. The Fundamental Structure of Base 16
In our everyday decimal system (base 10), we count from 0 to 9. When we need to represent the next number, we roll over into a new column: "10" represents 1 ten and 0 ones.
In the hexadecimal (base 16) system, numbers do not roll over at ten. Instead, counting continues through fifteen using six letters:
Only after fifteen does a rollover occur: 0x10 in hexadecimal equals sixteen in decimal!
2. The Special Relationship Between Hex and Binary
Why do programmers use hexadecimal instead of decimal or octal? The answer lies in digital electronics.
Every electronic transistor operates in binary: either high voltage (1) or low voltage (0). However, writing numbers in binary is tedious and error-prone. A 32-bit integer looks like:
Because 16 is an exact power of two (2⁴ = 16), four binary bits (a "nibble") map directly onto one hexadecimal digit:
The 32-digit binary string becomes a concise 8-digit hex value. Two hex digits constitute an entire 8-bit byte (0x00 to 0xFF).
3. Real-World Applications of Hexadecimal
- Web Color Codes (CSS): Colors in HTML and CSS are represented as three pairs of hexadecimal digits (
#RRGGBB). White is#FFFFFF(255 Red, 255 Green, 255 Blue), while pure black is#000000. - Memory Pointers: Debuggers and crash dumps format memory addresses in hex (e.g.
0x7FFF5FBFF8C0) because 64-bit addresses are much easier to read as 16 hex digits. - Media Access Control (MAC) Addresses: Network network interface cards (NICs) possess unique physical identifiers written as six hex byte pairs (e.g.
00:1A:2B:3C:4D:5E).