Binary, decimal and hexadecimal explained

Published by InstantToolDeck · Updated November 2026

Every number you write is a pattern of digits, and the base tells you how many different digits exist before you carry over to the next place. People count in base 10 because we have ten fingers. Computers work in base 2 because a circuit is either on or off. Hexadecimal, base 16, exists because it is a compact way for humans to read long binary numbers.

Positional notation

In decimal, the number 345 means 3×100 + 4×10 + 5×1. Each place is worth ten times the place to its right. The same idea works in any base: each place is worth the base times the place to its right. In binary the places are worth 1, 2, 4, 8, 16, 32 and so on, so 101101 is 32 + 8 + 4 + 1 = 45.

BaseNameDigits usedWhere you meet it
2Binary0, 1Machine data, bit flags, networking masks
8Octal0–7Unix file permissions such as 755
10Decimal0–9Everyday numbers
16Hexadecimal0–9, A–FColors, memory addresses, hashes, MAC addresses

Converting decimal to another base

Divide the number by the target base, write down the remainder, then repeat with the quotient until it reaches zero. Read the remainders from last to first. For 45 to binary: 45 ÷ 2 = 22 remainder 1; 22 ÷ 2 = 11 remainder 0; 11 ÷ 2 = 5 remainder 1; 5 ÷ 2 = 2 remainder 1; 2 ÷ 2 = 1 remainder 0; 1 ÷ 2 = 0 remainder 1. Reading upward gives 101101.

Converting to decimal

Multiply each digit by its place value and add. For hex 2F: 2×16 + 15×1 = 47, because F stands for 15. The Number Base Converter does this instantly for any size of number, and the hex to decimal and decimal to binary pages are preset for those directions.

Why hex is a shortcut for binary

Sixteen is 2 to the power 4, so one hex digit holds exactly four bits. To convert binary to hex, split the bits into groups of four from the right and replace each group: 1111 1111 becomes FF, and 1010 0011 becomes A3. Going the other way, expand each hex digit to four bits. Octal does the same with groups of three bits, which is why file permissions fit neatly into three octal digits (rwx is 3 bits, so 7 means read, write and execute).

Prefixes and notation

Because 10 could mean ten, two or sixteen, programmers add prefixes: 0x for hex (0xFF), 0b for binary (0b1010) and 0o for octal (0o755). Some languages use a leading zero for octal, which is a classic source of bugs: in older code, 010 can mean eight.

Common mistakes

  • Mixing up letter case. ff and FF are the same value; case matters only for readability or when a format requires one.
  • Forgetting leading zeros. Binary and hex are often written with fixed width, such as 8 bits or two hex digits per byte, so 5 is shown as 00000101.
  • Negative numbers. Computers usually store them in two’s complement, where the top bit means negative. A converter that shows a plain minus sign (like ours) is not the same as the stored bit pattern.
  • Fractions. Many decimals, such as 0.1, have no exact binary form, which is why floating-point math sometimes surprises people.

Where you will use this

Web developers read hex in color codes (#1a73e8), network engineers read it in IPv6 and MAC addresses, and security work uses it for hashes and byte dumps. The Hex Calculator adds, shifts and masks values, and the Text to Binary Converter shows how letters are stored as bytes.

Frequently asked questions

How do I convert binary to hexadecimal?

Group the bits in fours from the right and replace each group with its hex digit, for example 1010 1111 is AF.

Why do computers use binary?

Electronic circuits have two reliable states, on and off, so binary is the simplest and most dependable way to store and process data.

What is 0xFF in decimal?

255. F is 15, so 15×16 + 15 = 255, the largest value one byte can hold.

Why does hex use letters?

Base 16 needs sixteen single-character digits. After 0–9, the letters A–F stand for 10–15.

← All guides