Number bases: how to convert binary, octal and hexadecimal

Learn how to convert between decimal, binary, octal and hexadecimal, understand place value, and see why hex appears in colors, memory and permissions.

255, FF and 11111111 represent the same number — only the base changes. Anyone working with programming, electronics or interface design runs into all three forms constantly, and mixing them up is a classic source of error: a color that should be white turns black, a file permission changes behavior.

This guide explains what a number base is, how to convert to decimal and back, the shortcuts between binary, octal and hexadecimal, and where each system shows up in daily work. To convert right now, use the number base converter.

What is a number base?

The base is the number of digits available in a numeral system. Decimal (base 10) uses 0 to 9. Binary (base 2) uses only 0 and 1. Octal (base 8) uses 0 to 7. Hexadecimal (base 16) uses 0 to 9 plus the letters A to F, which stand for 10 to 15.

Each digit's value depends on its position: in decimal, 352 means 3 × 100 + 5 × 10 + 2 × 1. The same logic applies to any base — only the number raised to the position changes.

How to convert to decimal

Add each digit multiplied by the base raised to its position, starting from zero on the right:

value = digit × baseposition

Examples:

How to convert from decimal to another base

The reverse path is repeated division: divide the number by the base, keep the remainder, and repeat with the quotient until it reaches zero. The result is formed by the remainders read from bottom to top.

To convert 42 to binary: 42 ÷ 2 = 21, remainder 0; 21 ÷ 2 = 10, remainder 1; 10 ÷ 2 = 5, remainder 0; 5 ÷ 2 = 2, remainder 1; 2 ÷ 2 = 1, remainder 0; 1 ÷ 2 = 0, remainder 1. Reading bottom to top: 101010.

The same 42 in octal is 52 (42 ÷ 8 = 5, remainder 2; 5 ÷ 8 = 0, remainder 5) and in hexadecimal it is 2A (42 ÷ 16 = 2, remainder 10 = A; 2 ÷ 16 = 0, remainder 2).

Shortcuts between binary, octal and hexadecimal

Because 8 and 16 are powers of 2, converting between these systems is simpler than it looks:

That is why 1111 1111 in binary is FF in hexadecimal and 255 in decimal. And the Unix permission 755 becomes 111 101 101 in binary — each digit represents a combination of read, write and execute.

Where this shows up in daily work

Common mistakes when converting bases

Convert without doing the math

In the number base converter, type the number, choose the input base and see the equivalent in decimal, binary, octal and hexadecimal at the same time. Validation warns you when a digit does not belong to the selected base — handy for quickly checking a color, a permission or a debugging value.