Convert to Binary

Converts a number to binary from decimal or any other base up to 36, exactly, for an entry of any length.

Binary notation shows how a number sits in memory: two symbols, 0 and 1, and each next position doubles the previous one. That also sets the length of the notation: the decimal 156 takes three digits, while the binary 10011100 takes eight.

How the conversion works

The number is divided by two over and over, keeping the remainders, and the remainders are read from the bottom up. For 156: 156 = 78 remainder 0, 78 = 39 remainder 0, 39 = 19 remainder 1, 19 = 9 remainder 1, 9 = 4 remainder 1, 4 = 2 remainder 0, 2 = 1 remainder 0, 1 = 0 remainder 1. Read from the bottom up, the remainders give 10011100. You can check it by adding powers of two: 128 + 16 + 8 + 4 = 156.

How many digits you get

One byte holds eight binary digits, and fits numbers from 0 to 255. Two bytes go up to 65,535, four bytes to 4,294,967,295. The number 18,446,744,073,709,551,615 takes exactly 64 digits, all ones; some calculators stumble on it because they count with floating point. Here the length of the notation is limited only by common sense.

Leading zeros are dropped from the answer: 00001010 and 1010 are the same number. Spaces and underscores between digits are fine in the input, they get skipped: 1010 1100 is read as 10101100.

Rate this tool

Help us get better

Other tools