Guide
Hex vs Decimal
Same numbers, different questions answered. Which notation belongs where.
The difference in one line
Decimal tells you how much. Hex tells you which bits.
Both describe identical values. What differs is what the notation makes obvious and what it hides.
| Decimal | Hexadecimal | |
|---|---|---|
| Base | 10 | 16 |
| Digits | 0–9 | 0–9, A–F |
| Bits per digit | About 3.32 — not a whole number | Exactly 4 |
| One byte | 0–255, one to three digits | 00–FF, always two digits |
| Makes obvious | Magnitude and arithmetic | Bit patterns and byte boundaries |
| Hides | Which bits are set | Rough size at a glance |
The fixed-width property
This is the practical difference, and it matters more than it sounds.
four bytes in decimal 26 115 232 9 four bytes in hex 1A 73 E8 09 decimal: widths vary — you must count carefully hex: always two digits — boundaries are automatic
In a dump of a thousand bytes, hex columns line up perfectly and decimal columns do not. That is why every debugger, hex editor and packet analyser ever written displays hex.
Where decimal wins
- Quantities people care about. Prices, counts, measurements, ages. Nobody wants their bank balance in hex.
- Mental arithmetic. You have practised base 10 since childhood.
- Anything user-facing. Error codes shown to non-technical users, quantities in a UI, numbers in documentation aimed at a general reader.
- Rough comparison. You can see instantly that 1,000,000 is much bigger than
50,000.
F4240versusC350takes a moment longer.
Where hex wins
- Anything bit-related. Masks, flags, permissions, packed fields.
- Memory addresses. Alignment is visible — an address ending in
0is 16-byte aligned, and you can see that without dividing. - Fixed-width data. Bytes, words, registers, protocol fields.
- Identifiers. Hashes, UUIDs, MAC addresses. Compact and unambiguous.
- Color codes. Three bytes in six characters, with the channel split visible.
Is address 3,735,928,560 aligned to a 16-byte boundary? You would have to divide. Is DEADBEF0? Yes — the last digit is 0, and that is the whole check. This is the kind of question hex answers for free.
Side by side
| Decimal | Hex | Which is clearer, and why |
|---|---|---|
| 255 | FF | Hex — obviously a full byte |
| 1,000 | 3E8 | Decimal — a round human number |
| 16,777,215 | FFFFFF | Hex — obviously three full bytes |
| 4,294,967,295 | FFFFFFFF | Hex — obviously a 32-bit maximum |
| 3,600 | E10 | Decimal — it is an hour in seconds |
| 128 | 80 | Hex — obviously just the sign bit |
The pattern: if the number is meaningful to a person, decimal. If it is meaningful to the machine, hex.
Choosing in code
Most languages accept both and produce identical machine code, so the choice is purely about the reader.
// hex — the value is a bit pattern
flags &= 0xF0;
if (status & 0x80) { ... }
color = 0x1A73E8;
// decimal — the value is a quantity
if (retries > 3) { ... }
timeout = 5000;
for (int i = 0; i < 256; i++) { ... }
Writing flags &= 240 is legal and tells the reader nothing. Writing
timeout = 0x1388 is also legal and equally unhelpful. Match the notation to what the
number means.
Converting between them
Use the hex to decimal converter or the decimal to hex converter, or work through the methods by hand in the conversion tutorial.
Frequently asked questions
What is the difference between hex and decimal?
Decimal uses ten digits and hex uses sixteen. They express the same values, but hex makes bit patterns and byte boundaries visible while decimal makes magnitude easier to judge.
Why do programmers use hex instead of decimal?
Because one hex digit is exactly four bits and one byte is exactly two hex digits. Byte boundaries stay visible, which decimal cannot do.
Is hex faster for a computer?
No. The computer works in binary either way. The choice affects only human readability.
When should I write decimal in my code?
Whenever the number is a quantity: counts, limits, timeouts, sizes people reason about.
When should I write hex in my code?
Whenever the number is a bit pattern: masks, flags, addresses, color codes, protocol constants.
Which is bigger, FF or 255?
Neither. They are the same number written in two notations.