Binary and hexadecimal are both number systems computers use, but they serve different purposes. Binary is what hardware actually processes; hexadecimal is a human-friendly shorthand for reading binary. Here’s how they compare and when to use each.
The Short Answer
| Binary | Hexadecimal | |
|---|---|---|
| Base | 2 | 16 |
| Digits | 0, 1 | 0-9, A-F |
| 8 bits written as | 11111111 | FF |
| Used by | Hardware, CPUs | Programmers, developers |
Hexadecimal (hex) exists because binary strings get long and error-prone fast. The byte `11111111` is much easier to read and write as `FF`.
Why Hexadecimal Exists
One hex digit represents exactly 4 bits (a nibble). This makes conversion between binary and hex trivial – just group bits in fours:
“`
Binary: 1111 0010 1010 1101
Hex: F 2 A D
“`
So `1111001010101101` in binary is simply `F2AD` in hex. No math required, just a lookup of 16 values (0-9, A-F).
Compare that to converting binary to decimal, which requires multiplying each bit by its place value and summing. Hex is the natural “compression format” for binary.
The 16 Hex Digits
Hexadecimal needs 16 symbols. It uses 0-9 for values zero through nine, then A-F for ten through fifteen:
| Hex | Decimal | Binary |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 5 | 5 | 0101 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Where You See Hexadecimal in Real Life
Hex is everywhere in computing, usually wherever a human needs to read raw binary data:
- Color codes: `#FF5733` – each pair of hex digits is one byte (red=FF, green=57, blue=33).
- Memory addresses: Debuggers show addresses like `0x7FFE2A4B`.
- MAC addresses: `AA:BB:CC:DD:EE:FF` – six bytes written as hex pairs.
- Error codes: Windows blue screens show codes like `0x0000007B`.
- Unicode: The emoji 😀 is U+1F600 – a hex code point.
- Cryptographic hashes: SHA-256 outputs 64 hex characters.
The `0x` prefix is the standard way to mark a number as hexadecimal in programming (so `0xFF` = 255, not the letters F-F).
What About Octal?
You may occasionally encounter octal (base 8, digits 0-7). It was popular in early computing (the PDP-8, Unix file permissions) because 8 = 2³ – one octal digit maps to exactly 3 bits, just as one hex digit maps to 4 bits.
Unix permissions are the most common place octal survives: `chmod 755` means binary `111 101 101` (owner: read+write+execute, group: read+execute, others: read+execute). Hexadecimal won everywhere else because 4-bit grouping aligns with bytes (two hex digits = one byte exactly), while 3-bit octal grouping doesn’t divide 8-bit bytes evenly.
For modern work, learn binary and hex thoroughly; treat octal as a historical curiosity you’ll recognize when you see `0755` in old scripts.
When to Use Binary vs Hex
Use binary when:
- Learning how computers represent data at the hardware level
- Working with individual bits (flags, bitmasks, permissions)
- Understanding logic gates and CPU operations
Use hex when:
- Reading memory dumps or debug output
- Writing color codes in CSS/HTML
- Working with byte-level data (networking, file formats)
- You need compact, readable representation of binary data
In practice, developers think in hex and let the computer handle binary. You can convert between them instantly with our binary converter – it shows binary, hex, decimal, and text representations side by side.
Worked Example: The Same Byte Three Ways
Take the letter M:
- Text: M
- Decimal: 77
- Binary: 01001101
- Hexadecimal: 4D
Check: 4D in hex = 4×16 + 13 = 64 + 13 = 77. ✓ And 01001101 in binary = 64 + 8 + 4 + 1 = 77. ✓
All three are the same value – just different ways of writing it. Paste `01001101` into our binary converter to see all representations at once.
Frequently Asked Questions
Is hexadecimal the same as binary?
No. Binary is base-2 (digits 0-1) and hexadecimal is base-16 (digits 0-9, A-F). They’re related because one hex digit maps exactly to 4 binary bits, making conversion between them trivial.
Why is hex used instead of just decimal?
Decimal doesn’t align with binary the way hex does. One hex digit = exactly 4 bits = exactly half a byte. There’s no such clean mapping between decimal digits and bits, so converting binary to decimal requires real arithmetic while binary-to-hex is just regrouping.
What does 0x mean in front of a number?
The `0x` prefix indicates a hexadecimal literal in most programming languages (C, Python, JavaScript, Java). So `0xFF` means hex FF = decimal 255. Without the prefix, `FF` would be interpreted as an identifier or cause a syntax error.
How do I convert hex to binary quickly?
Replace each hex digit with its 4-bit binary equivalent: F→1111, A→1010, 3→0011. So `FA3` becomes `1111 1010 0011`. Drop leading zeros if you want: `111110100011`.