Hexadecimal, binary and decimal: a guide to understanding them

If you program or study computing, sooner or later you meet numbers in binary or hexadecimal: colours like #FF6600, permissions like 755 or memory addresses like 0xDEADBEEF. This guide explains what these number systems are, why they exist and how to convert between them by hand, with fully worked examples.

Why different systems exist

The decimal system (base 10) is the one we use daily — most likely because we have ten fingers. Computers, on the other hand, work in binary (base 2: only 0 and 1) because their circuits can reliably distinguish two electrical states: voltage present or absent. Each of those binary digits is a bit, and eight bits form a byte.

The trouble with binary is that it gets very long for humans: the number 2026 needs eleven bits. That is where hexadecimal (base 16) comes in, using the digits 0–9 plus the letters A–F. Its superpower is that each hex digit corresponds to exactly 4 bits, so it works as shorthand for binary: a full byte is always written with exactly two hex digits. That is why you see it in web colours, memory dumps and MAC addresses.

The key idea: positional notation

In any base, the value of a digit depends on its position. In decimal, 3,482 means 3×1,000 + 4×100 + 8×10 + 2×1: each position is worth ten times the one to its right. In binary each position is worth twice the previous one (1, 2, 4, 8, 16, 32, 64, 128…), and in hexadecimal, sixteen times (1, 16, 256, 4,096…).

With that idea, the same number can be written in all three bases:

Three representations, one value. No base is "more correct" than another: each is convenient in its own context.

How counting works in each base

This equivalence table is worth memorising at least up to 15, because it is what lets you translate between binary and hexadecimal at a glance:

DecimalBinaryHexadecimal
000000
501015
910019
101010A
121100C
151111F
161000010
451011012D
25511111111FF
2026111111010107EA

Careful: "10" does not mean the same thing in every base. In binary it is two, in decimal ten and in hexadecimal sixteen. That is why programming languages use prefixes: 0b1010 for binary and 0xA for hexadecimal.

Converting step by step

Decimal to binary: repeated division

Divide by 2 over and over, note the remainders, then read them from bottom to top. Let's convert 2026:

2026 in binary

  • 2026 ÷ 2 = 1013, remainder 0
  • 1013 ÷ 2 = 506, remainder 1
  • 506 ÷ 2 = 253, remainder 0  ·  253 ÷ 2 = 126, remainder 1
  • 126 ÷ 2 = 63, remainder 0  ·  63 ÷ 2 = 31, remainder 1
  • 31 ÷ 2 = 15, remainder 1  ·  15 ÷ 2 = 7, remainder 1
  • 7 ÷ 2 = 3, remainder 1  ·  3 ÷ 2 = 1, remainder 1  ·  1 ÷ 2 = 0, remainder 1

Reading the remainders from last to first: 11111101010. So 2026 = 0b11111101010.

Binary to decimal: sum of powers

Give each bit its positional value starting with 1 on the right and doubling as you move left; then add up the positions holding a 1. For 10101101: 128 + 32 + 8 + 4 + 1 = 173.

Binary to hexadecimal (and back): groups of 4 bits

Group the bits in fours starting from the right and translate each group using the table above. If the leftmost group is incomplete, pad it with zeros:

11111101010 → 0111 1110 1010 → 7 E A → 0x7EA

The reverse trip is just as direct: each hex digit expands to its 4 bits. This instant translation is exactly why hexadecimal is the preferred base for displaying binary data.

Decimal to hexadecimal: division by 16

Same method as with binary, but dividing by 16: 2026 ÷ 16 = 126 remainder 10 (A); 126 ÷ 16 = 7 remainder 14 (E); 7 ÷ 16 = 0 remainder 7. Reading bottom-up: 7EA. It matches the bit-grouping result, as it should. You can check any of these exercises with our hex-binary converter.

Where you meet them in practice

Common conversion mistakes

Frequently asked questions

Do computers calculate in hexadecimal?

No: internally everything is binary. Hexadecimal is just a convenient notation so humans can read and write those bits without slipping up.

Why does 255 appear so often in computing?

Because it is the maximum value of one byte: eight bits all set to 1 (11111111 = 0xFF). That is why RGB colour channels run from 0 to 255 and why it shows up in network masks.

What is octal still used for?

Its main modern use is file permissions on Unix/Linux systems, because each octal digit encodes the 3 bits for read, write and execute.

How can I check my conversions?

Do the exercise by hand and verify the result with a tool: if the decimal value matches in both directions, your conversion is correct.

Convert between hexadecimal, binary, octal and decimal instantly, and check your practice exercises.

Hex-binary converter →