Binary, Hex & Decimal Converter

Convert a whole number between binary, octal, decimal, hexadecimal and any base up to 36.

Binary, Hex & Decimal Converter by AIPreciseTools ยท Open the full calculator โ†—

How base conversion works

To decimal: multiply each digit by the base raised to its position, counting from 0 on the right, and add From decimal: divide by the new base repeatedly; the remainders, read bottom to top, are the digits

Example: binary 11111111 is 1ร—2โท + 1ร—2โถ + โ€ฆ + 1ร—2โฐ = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. In hexadecimal that's FF (15 ร— 16 + 15), and in octal 377.

Decimal to binary: 13 รท 2 = 6 r1, 6 รท 2 = 3 r0, 3 รท 2 = 1 r1, 1 รท 2 = 0 r1. Reading the remainders from the last one up gives 1101.

Why programmers use hex

Each hexadecimal digit stands for exactly four binary digits, so long binary numbers shrink to a quarter of the length and convert back by sight: 1111 1111 is FF, 1010 0101 is A5. That's why colors (#FF8800), memory addresses and byte values are written in hex. Octal does the same with groups of three bits and still appears in Unix file permissions such as 755.

The converter uses whole-number math with no size limit, so even very long numbers convert exactly. Prefixes such as 0x, 0b and 0o are accepted, along with spaces and underscores between digit groups.

Frequently asked questions

How do I convert binary to decimal?

Write the place values 1, 2, 4, 8, 16 and so on from the right, and add the ones under each 1. 1011 is 8 + 2 + 1 = 11.

What is 255 in hex?

FF. It's the largest value that fits in one byte, which is why it shows up so often in colors and networking.

What digits does hexadecimal use?

0 to 9 and then A to F for the values 10 to 15.

Was this calculator helpful?