The four number bases
Binary (base 2) uses the digits 0 and 1 and is how computers store data. Octal (base 8) uses 0–7 and still appears in Unix file permissions such as 755. Decimal (base 10) is everyday counting. Hexadecimal (base 16) uses 0–9 and A–F, where A = 10 and F = 15; it is used for colors (#FF8800), memory addresses and byte values.
Decimal to binary, octal or hex
Divide the number repeatedly by the target base and write the remainders from last to first. Example: 2026 ÷ 16 = 126 remainder 10 (A); 126 ÷ 16 = 7 remainder 14 (E); 7 ÷ 16 = 0 remainder 7, so 2026 = 7EA in hex. The same method gives 11111101010 in binary and 3752 in octal.
Binary, octal or hex to decimal
Multiply each digit by the base raised to its position, counting from 0 at the right, and add the results. Hex 7EA = 7 × 16² + 14 × 16 + 10 = 1,792 + 224 + 10 = 2,026. Binary 1011 = 8 + 0 + 2 + 1 = 11.
Shortcut between binary and hex or octal
Each hex digit is exactly four binary digits and each octal digit is three. Split binary into groups from the right: 1111 1110 1010 is F E A, but with the leading group 111 1110 1010 it reads 7EA. For octal, 11 111 101 010 gives 3 7 5 2.
Quick reference
Decimal 10 = binary 1010 = octal 12 = hex A. Decimal 15 = 1111 = 17 = F. Decimal 16 = 10000 = 20 = 10. Decimal 100 = 1100100 = 144 = 64. Decimal 255 = 11111111 = 377 = FF (the largest value of one byte). Decimal 1024 = 10000000000 = 2000 = 400.