ToolDash
Decimal to Binary Converter

Decimal to Binary Converter

Enter a whole number and get its binary form, along with the repeated division by 2 that produces it, so you can learn the method or check your own working.

  • Free, no sign-up
  • Runs in your browser — nothing is uploaded
  • Instant results, no waiting on a server

Type a decimal number to get it in binary, with the divide-by-2 steps that produce each bit.

Input base

Try a value in decimal

Decimal → Binary

—

Binary (base 2)

—

Octal (base 8)

—

Decimal (base 10)

—

Hexadecimal (base 16)

—

How to convert decimal to binary with this tool

  1. 1Type a non-negative whole number into the Value field. Decimal is already selected as the input base.
  2. 2Read the binary result in the highlighted box at the top.
  3. 3Follow the Working section: the number is divided by 2 again and again, and the remainders, read from the last line up, are the bits.
  4. 4Copy the binary with the copy icon, or take the hexadecimal and octal forms from the results below.

How to convert decimal to binary by hand

The standard method for going from base 10 to base 2 is repeated division by 2. Divide the number by 2 and write down the remainder, which is always 0 or 1. Divide the quotient by 2 again and repeat until the quotient reaches 0. The remainders read from the last one to the first are the binary number. For 156: 156 / 2 = 78 r 0, 78 / 2 = 39 r 0, 39 / 2 = 19 r 1, 19 / 2 = 9 r 1, 9 / 2 = 4 r 1, 4 / 2 = 2 r 0, 2 / 2 = 1 r 0, 1 / 2 = 0 r 1. Reading upward gives 10011100.

It works because each remainder is the lowest bit of the number at that stage, and dividing by 2 shifts the remaining bits one place to the right. The first remainder is the ones bit and the last is the highest bit, which is why you read them in reverse.

The other common method subtracts powers of 2. Find the largest power of 2 that fits, subtract it, and repeat with the rest. 156 - 128 = 28, 28 - 16 = 12, 12 - 8 = 4, 4 - 4 = 0. Put a 1 in the 128, 16, 8 and 4 places and 0 everywhere else, and you get 10011100 again. The number of bits you need is one more than the largest power of 2 used: 1,000 needs 10 bits because 512 is the largest power of 2 not above it.

Programs often want a fixed width, so pad with leading zeros: 5 is 101, or 00000101 as a byte. Negative numbers are usually stored in two's complement: write the positive value at the chosen width, invert every bit and add 1, so -5 in 8 bits is 11111011. This converter handles non-negative whole numbers. Fractions are a different story, since many decimals such as 0.1 have no exact binary form and repeat forever (0.000110011...), which is the source of floating-point rounding errors.

Why you'd convert decimal to binary

Learning number systems

See the full division table for any number and compare it with your own working.

Building bit masks

Turn a decimal flag value or permission number into bits to see which options it switches on.

Subnetting

Convert IP address octets and prefix sizes to binary to work out network and host bits.

Embedded and hardware work

Get the bit pattern to write into a register, shift register or set of output pins.

Frequently asked questions

What is 10 in binary?

+

1010. 10 / 2 = 5 r 0, 5 / 2 = 2 r 1, 2 / 2 = 1 r 0, 1 / 2 = 0 r 1, and reading the remainders upward gives 1010, which is 8 + 2.

How do I convert decimal to binary in code?

+

To turn an integer to binary in JavaScript use (156).toString(2), or BigInt for numbers above 2^53. In Python use bin(156), which returns '0b10011100', or format(156, '08b') for a zero-padded 8-bit string.

How many bits does a number need?

+

Find the largest power of 2 that isn't bigger than the number; its exponent plus one is the bit count. 255 needs 8 bits, 256 needs 9, and 1,000 needs 10.

How do I write a negative number in binary?

+

Most systems use two's complement: write the positive number at a fixed width, flip every bit, then add 1. -5 as 8 bits is 00000101 flipped to 11111010, plus 1 = 11111011. This tool converts non-negative numbers only.

Can it convert very large numbers?

+

Yes. The conversion uses BigInt, so even a 30-digit number converts exactly. The division steps are listed for results up to 64 bits.