The short answer
Hexadecimal (base 16) uses digits 0-9 and letters A-F, where each position represents a power of 16. FF in hex equals 15×16 + 15 = 255 in decimal — the largest value a single byte can hold. Programmers use hex because it maps cleanly onto binary: one hex digit always equals exactly 4 bits, so two hex digits represent a full byte.
Key takeaways
- Two hex digits equal one byte (8 bits) — a value from 00 to FF (0 to 255) — which is why memory addresses, byte values, and color codes are almost always shown in hex.
- Converting hex to binary is mechanical: replace each hex digit with its 4-bit binary equivalent and join them together.
- Hex arithmetic follows the same carrying and borrowing logic as decimal arithmetic, just with a base of 16 instead of 10.
- Web colors (#RRGGBB) pack three byte values — red, green, blue — into six hex digits, two per color channel.
Hex digit values (0-F)
| Hex | Decimal | Hex | Decimal |
|---|---|---|---|
| A | 10 | D | 13 |
| B | 11 | E | 14 |
| C | 12 | F | 15 |
Converting decimal to hex
202 ÷ 16 = 12 remainder 10 → A
12 ÷ 16 = 0 remainder 12 → C
Read remainders bottom to top: CA
So decimal 202 equals hex CA. Checking in reverse: C×16 + A = 12×16 + 10 = 192 + 10 = 202 — confirming the conversion.
Worked example: hex addition
3A + 1F
A (10) + F (15) = 25 = 1×16 + 9 → write 9, carry 1
3 + 1 + carry 1 = 5
Result: 59
Checking in decimal: 3A = 58, 1F = 31, and 58 + 31 = 89, which is 5×16 + 9 = 0x59 — matching the hex arithmetic exactly. The only real difference from decimal addition is that a carry happens once a column reaches 16, not 10.
Common mistakes to avoid
- Carrying at 10 out of habit instead of 16 — a hex column carries once its value reaches 16, not 10 like decimal.
- Assuming a single hex digit is one bit — it always represents 4 bits, since 16 = 2⁴.
- Dropping a leading zero on a fixed-width byte or color channel — 0x0A and 0xA are the same value, but a two-digit byte display expects 0A, not A.
- Mixing digit case inconsistently — hex is case-insensitive (a = A = 10), but sticking to one case avoids visual confusion in longer values.
Related calculators
- Binary Calculator — work directly in base-2 alongside hex conversions.
- Big Number Calculator — handle values that outgrow standard hex arithmetic ranges.
- Exponent Calculator — check the powers of 16 behind each hex digit's place value.
- Basic Calculator — handle everyday decimal arithmetic outside any specific base.