Decimal to Binary Converter

Enter a decimal (base-10) number to get its binary form, with the division-by-two working shown below.

Loading tool…

About the Decimal to Binary

The classic method is repeated division by 2. Divide the number by 2, write down the remainder (0 or 1), and repeat with the quotient until it reaches 0. The remainders read from the last to the first are the binary digits. For 214: 214÷2 = 107 r0, 107÷2 = 53 r1, 53÷2 = 26 r1, 26÷2 = 13 r0, 13÷2 = 6 r1, 6÷2 = 3 r0, 3÷2 = 1 r1, 1÷2 = 0 r1 — read upward, 11010110. The working table below the result does this for your number.

A second method subtracts the largest power of two that fits: 214 − 128 = 86, 86 − 64 = 22, 22 − 16 = 6, 6 − 4 = 2, 2 − 2 = 0, so bits 128, 64, 16, 4 and 2 are set. Both give the same answer; division is easier to do mechanically, subtraction is faster if you know the powers of two.

The result is grouped in nibbles (4 bits) and padded to whole bytes, which makes it easy to read against a hex dump — each nibble is one hex digit. A negative input gets a minus sign in front of the magnitude; to see how a CPU actually stores a negative integer (two's complement at a fixed width) use the number base converter. Numbers of any size are converted exactly with BigInt.

How to use it

  1. Type a whole decimal number (commas and spaces are ignored).
  2. Read the binary result and its grouped byte view.
  3. Follow the repeated-division table to see where each bit comes from.
  4. Copy the result, or use the octal and hex values below it.

Frequently asked questions

How do you convert decimal to binary?
Divide by 2 repeatedly and record the remainders; read them from last to first. 13 → 6 r1 → 3 r0 → 1 r1 → 0 r1, so 13 = 1101.
What is 255 in binary?
11111111 — eight ones, the maximum value of an unsigned byte.
How many bits does a number need?
floor(log2(n)) + 1 bits for n ≥ 1. 1000 needs 10 bits because 2^9 = 512 ≤ 1000 < 1024 = 2^10. The status next to the input shows the bit count.
How do I convert decimal to binary in code?
JavaScript: (214).toString(2). Python: bin(214) gives '0b11010110', or format(214, 'b'). Java: Integer.toBinaryString(214).

Related tools