How to convert decimal to binary with this tool
- 1Type a non-negative whole number into the Value field. Decimal is already selected as the input base.
- 2Read the binary result in the highlighted box at the top.
- 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.
- 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.
Related tools
Binary to Decimal Converter
Convert binary to decimal instantly and see the place values that add up to the result. Works for any number of bits.
Hex to Decimal Converter
Convert hexadecimal to decimal as you type, with the positional working shown digit by digit. Exact for values of any size.
Binary, Hex & Decimal Converter
Convert numbers between binary, octal, decimal, and hexadecimal. Real-time conversion with input validation and BigInt precision for large values.
Chmod Calculator
Work out Unix file permissions: tick read/write/execute for owner, group and others, or type an octal mode like 755 or a string like rwxr-xr-x. Get the chmod command in numeric and symbolic form, including setuid, setgid and sticky bits.