Binary ↔ Hex ↔ Decimal
You've counted in binary. Now let's add two more number systems computers — and programmers — use constantly.
Swipe or tap Next for the next section
Same Value, Different Base
Decimal, binary, and hexadecimal are just three different ways of writing the exact same number. Decimal counts in groups of 10 (probably because we have 10 fingers). Binary counts in groups of 2 — the only options a computer's circuits actually have. Hexadecimal counts in groups of 16, and exists purely as a convenience for humans.
None of them change what the number is — only how it's written down.
Counting in Hexadecimal
Hex needs 16 digits, so it borrows letters once the numbers run out: 0, 1, 2 … 9, A, B, C, D, E, F. Each hex digit represents exactly 4 bits — a "nibble" — so a whole byte is always exactly two hex digits.
Remember the byte from the last lesson, 10110010? Split into two 4-bit halves, each half converts to one hex digit:
Why Programmers Use Hex
Nobody's typing hex for fun — it's just far more compact than binary and lines up perfectly with bytes (2 hex digits = 1 byte, always). You'll see hex show up in memory addresses, and anywhere programmers need to talk about raw bytes without writing out 8 digits at a time.
It's also how colors are written on the web. This site's own accent color is #FFAE2E — three bytes glued together, one each for red (FF), green (AE), and blue (2E).
Converting Between Them
Binary to decimal: add up the value of each "on" bit (1, 2, 4, 8, 16 …) — exactly what you learned on the What is Binary? page. Binary to hex: split into groups of 4 and convert each nibble separately, as above. Going the other direction just reverses the steps.
Try It Yourself
Practice
Decimal, binary, hex — can you convert between all three? Ten questions, one focused round.