Decimal to Binary

A decimal point is fine — 12.625 comes out as 1100.101.

Enter a decimal number and press Convert. The answer and the working behind it will show up here.

— —
Working out

The whole part: divide by 2

Divide the whole number by 2 again and again, keeping each remainder. Read the remainders from last to first. For 156: the remainders are 0, 0, 1, 1, 1, 0, 0, 1, so reading upwards gives 10011100. Check by adding place values: 128 + 16 + 8 + 4 = 156. ✓

The fractional part: multiply by 2

For the part after the point, do the opposite: multiply by 2 and write down the whole number that appears, then carry on with what is left over. Read the digits downwards.

0.625: × 2 = 1.25 → digit 1. 0.25 × 2 = 0.5 → digit 0. 0.5 × 2 = 1.0 → digit 1, and we are left with nothing. So 0.625 = 0.101 in binary. Joined to the whole part, 156.625 = 10011100.101.

When a decimal never ends in binary

Try 0.1. Doubling gives 0.2, 0.4, 0.8, 1.6, 1.2, 0.4 … and the pattern repeats forever: 0.0001100110011… A fraction ends in binary only if its bottom, in lowest terms, is a power of 2. A tenth is not, so no finite number of bits is exact.

This is the reason that in many programming languages 0.1 + 0.2 comes out as 0.30000000000000004. The computer stores a rounded binary version of each. The calculator tells you whether the fraction ends or repeats, and cuts it off at a fixed number of bits when it repeats.

Octal and hex alongside

The whole part is also shown in octal and hexadecimal. Group the binary digits in threes for octal and in fours for hex. 10011100 is 1001 1100, which is 9C in hex.