Hexadecimal Number System
What you'll learn: How base-16 notation makes it easier to read and write binary values.
Why Hexadecimal Exists
You've been working with binary (base-2) and decimal (base-10). Binary is how computers think, but it gets unwieldy fast—imagine writing 11010110101111001010 every time! Hexadecimal (base-16) is a compact shorthand for binary that humans can actually work with.
How Hexadecimal Works
Hexadecimal uses 16 symbols to represent values:
- 0-9 for values zero through nine
- A-F for values ten through fifteen
Here's the mapping:
Decimal: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
The Magic Connection to Binary
The beauty of hexadecimal is that one hex digit represents exactly four binary digits (bits). This is because 16 = 2⁴.
For example:
- Binary
1111= Decimal15= HexF - Binary
1010= Decimal10= HexA - Binary
0101= Decimal5= Hex5
To convert a longer binary number to hex, group it into chunks of four bits from right to left:
Binary 11010110 → Group as 1101 0110 → Hex D6
Think of hex as a compression format for binary—instead of writing 8 binary digits, you write 2 hex digits. Same information, far more readable!
Why Programmers Love Hex
When you see memory addresses, color codes (like #FF5733), or low-level data, they're usually in hexadecimal because it strikes the perfect balance: close to how computers work (binary) but compact enough for humans to read.
Key Takeaway: Hexadecimal (base-16) uses digits 0-9 and letters A-F, with each hex digit representing exactly four binary bits, making it a compact and readable way to work with binary data.