Number converter · Free · No sign-up

Decimal to Binary Converter

Short answer

To convert decimal to binary, divide by 2 again and again, writing down each remainder, then read the remainders from the last to the first. 156 gives 0, 0, 1, 1, 1, 0, 0, 1, so it is 10011100. For a fraction, multiply by 2 and take each whole part. Negative numbers use two's complement.

Every division shown.

10011100In decimal: 156.156 in decimal =
  1. Divide 156 by 2 again and again, writing down each remainder.
  2. 156 ÷ 2 = 78 remainder 0
  3. 78 ÷ 2 = 39 remainder 0
  4. 39 ÷ 2 = 19 remainder 1
  5. 19 ÷ 2 = 9 remainder 1
  6. 9 ÷ 2 = 4 remainder 1
  7. 4 ÷ 2 = 2 remainder 0
  8. 2 ÷ 2 = 1 remainder 0
  9. 1 ÷ 2 = 0 remainder 1
  10. Read the remainders from the last to the first: 10011100.
The number in every common base
FormValue
Binary (base 2)10011100
Octal (base 8)234
Decimal (base 10)156
Hexadecimal (base 16)9C
Binary in groups of four1001 1100

The figures above are an example: put in your own decimal number, such as 1,234.5 or -42. Spaces and underscores between digit groups are ignored, and 0b, 0o, 0x or # in front are read when they match the base. Worked out exactly in this browser and kept there; nothing is sent anywhere. Going the other way? Use binary to decimal.

Type a decimal number, including a fraction or a minus sign, and read the binary with each division by 2 listed. Turn on two's complement to see a negative number as the bit pattern a computer stores.

Decimal to binary conversion rewrites an everyday base-10 number in base 2, using only 0 and 1, by finding which powers of 2 add up to it.

  • No sign-up
  • Nothing uploaded
  • Shows every step
  • Works offline
  • Exact, any size

Key facts

Decimal to binary converter at a glance
DetailAnswer
Method shownDivide by 2, keep the remainders, read them upwards
Example156 = 10011100
FractionsMultiply by 2 and keep the whole parts; 0.1 = 0.0(0011), repeating
Negative numbersTwo's complement at 8, 16, 32 or 64 bits: −42 = 11010110 at 8 bits
SizeUp to 256 characters, exact
Where your numbers are keptThis browser only

How to convert decimal to binary by hand

Repeated division, the method the converter lists, works for any whole number.

  1. Divide the number by 2

    Write the whole-number answer and the remainder, 0 or 1.

  2. Divide the answer by 2 again

    Keep going until the answer is 0.

  3. Read the remainders upwards

    The last remainder is the leftmost bit.

  4. For a fraction, multiply by 2

    The whole part, 0 or 1, is the next bit after the point; keep the rest.

  5. Stop when the fraction ends or repeats

    A remainder seen before means the bits repeat from there.

  6. For a negative, invert and add 1

    At a fixed width, for two's complement.

Who converts decimal to binary

Anyone who needs to see the bits behind an ordinary number.

  • Students

    Base-conversion homework with every division to compare.

  • Programmers

    Bit masks, flags and shifts worked out from decimal.

  • Network engineers

    Octets of an address or mask written as bits.

  • Electronics builders

    Values for DIP switches, LEDs and registers.

  • Teachers

    Worked examples, including why 0.1 repeats.

  • Game and puzzle makers

    Binary clues made from a number.

Why 0.1 has no exact binary form

Whole numbers always convert to a finite string of bits. Decimal fractions mostly do not. A fraction ends in binary only if, in lowest terms, its denominator is a power of 2: 0.5 is 1/2, 0.75 is 3/4 and 0.625 is 5/8, so they end. 0.1 is 1/10, and 10 has a factor of 5, so the doubling never comes out even and the bits repeat for ever. The Python tutorial on floating point makes the same point: in base 2, 1/10 is an infinitely repeating fraction, and a computer stores only the nearest value it can hold, which is why 0.1 + 0.1 + 0.1 does not compare equal to 0.3 in most languages.

Decimal fractions in binary
DecimalAs a fractionBinaryEnds?
0.51/20.1Yes
0.251/40.01Yes
0.753/40.11Yes
0.6255/80.101Yes
0.11/100.0(0011)No, 0011 repeats
0.21/50.(0011)No
0.33/100.0(1001)No
0.3753/80.011Yes

The converter follows the multiplication until the fraction ends or a remainder comes round again, then puts the repeating block in brackets, so 0.1 is shown exactly as 0.0(0011) rather than as 20 rounded digits. If the repeat is longer than 64 places, the result is cut there with an ellipsis and the working says so.

The other method: subtract powers of 2

Repeated division is the method most courses teach, but there is another that many people find easier for numbers under a few thousand: take away the largest power of 2 that fits, mark a 1 in its place, and repeat with what is left. Every power you skip is a 0.

156 by subtracting powers of 2
Power of 2Fits into what is left?BitLeft over
128Yes, 156 − 128128
64No028
32No028
16Yes, 28 − 16112
8Yes, 12 − 814
4Yes, 4 − 410
2No00
1No00

Reading the bit column down gives 10011100, the same as the remainders read upwards in the converter’s working. The subtraction method shows directly which powers make up the number (156 = 128 + 16 + 8 + 4), which is handy for bit flags and permission masks.

Negative numbers: two's complement step by step

Binary has no minus sign inside a computer. A negative number is stored as a two’s complement pattern of a fixed width: write the positive number in that width, invert every bit, and add 1. Choose a width in the converter and it does exactly that, with each step shown, and refuses a number that does not fit.

Negative numbers as two’s complement patterns
Decimal8-bit16-bit
−11111 11111111 1111 1111 1111
−21111 11101111 1111 1111 1110
−421101 01101111 1111 1101 0110
−1001001 11001111 1111 1001 1100
−1281000 00001111 1111 1000 0000
−129Does not fit1111 1111 0111 1111

Widening a negative number copies its sign bit into the new places (sign extension), which is why −42 gains eight 1s in 16 bits rather than eight 0s. Positive numbers gain 0s. The Cornell notes on two’s complement show the same invert-and-add-one rule at 8 and 32 bits.

Common decimal numbers in binary

Some values come up again and again in computing, because they are powers of 2 or one less than one.

Common decimal numbers in binary
DecimalBinaryWhy it matters
101010The usual first exercise
151111The largest 4-bit value: one hex digit, F
161000024
1001100100Seven bits
1271111111The largest signed byte
1281000000027, the top bit of a byte
25511111111The largest byte; each part of 255.255.255.0
25610000000028: the first number a byte cannot hold
10001111101000Ten bits
102410000000000210: one kibi, as in KiB

1024 is the binary thousand. Because 210 is close to 1,000, it was long used for a kilobyte; NIST’s page on binary prefixes records that the IEC named it the kibi (KiB) in 1998 so that kilo can keep meaning exactly 1,000.

What this page does not do

This page turns a decimal number into base 2. It does not turn text into binary letter codes, and it does not show the IEEE 754 bit layout a computer uses to store 0.1 as a float; it shows the true binary value, repeating digits and all. Up to 256 characters, worked exactly.

To write a whole word in binary, one byte per letter, use the text to binary converter instead; A is 01000001 there.

What this page does and does not do
It doesIt does not
Whole numbers of any size, exactlyRound through floating point
Decimal fractions, repeats markedEncode text as binary
Negatives in 8, 16, 32 or 64-bit two’s complementShow float or double bit layouts

This converter or a typical one

This decimal to binary converter compared with a typical one
 This pageA typical one
Every division shownYes, numberedA table at best
Decimal fractionsExact, repeating bits markedRounded or refused
Negative numbersTwo's complement at your width, step by stepOften one fixed width, no steps
Numbers past 253ExactOften rounded
Your numbers leave the browserNeverVaries

Frequently asked questions

How do you convert decimal to binary?

Divide the number by 2 and write down the remainder, 0 or 1. Divide the answer by 2 again and repeat until it reaches 0. Read the remainders from the last one to the first. For 13: remainders 1, 0, 1, 1, so 13 is 1101. The converter lists every division.

What is 10 in binary?

10 in decimal is 1010 in binary: 8 + 2. Dividing gives remainders 0, 1, 0, 1, read upwards as 1010. As one byte it is written 00001010, with leading zeros that do not change the value. In hex the same number is A.

What is 255 in binary?

255 is 11111111: eight 1s, the largest value that fits in one byte, because 2^8 - 1 = 255. That is why each part of an IPv4 address or a colour channel stops at 255. 256 needs a ninth bit: 100000000.

How do you convert a decimal fraction to binary?

Multiply the fraction by 2. The whole part, 0 or 1, is the next bit after the point; keep the fractional part and repeat. 0.625 gives 1.25, then 0.5, then 1.0, so it is 0.101. Most fractions such as 0.1 never come out even and repeat for ever.

How do you write a negative number in binary?

Inside a computer, as a two's complement pattern of fixed width. Write the positive number in that many bits, invert every bit and add 1. -42 in 8 bits: 00101010, inverted 11010101, plus 1 gives 11010110. On paper you can also just write a minus sign: -101010.

Why is 0.1 + 0.2 not exactly 0.3 in programming?

Because 0.1 and 0.2 repeat for ever in binary, a computer stores the nearest binary fraction it can hold, slightly off. The two small errors add up, and the sum is not the stored value nearest to 0.3. This converter shows the true repeating binary instead of a rounded one.

What is 100 in binary?

100 is 1100100 in binary: 64 + 32 + 4. It needs seven bits because 64 is the largest power of 2 below 100. As a byte it is 01100100. In hex it is 64, which is easy to mix up with decimal 64.

How many bits does a decimal number need?

Find the largest power of 2 that is not more than the number; the bit count is that power's exponent plus one. 1000 is between 512 (2^9) and 1024 (2^10), so it needs 10 bits. A signed number needs one extra bit for the sign.

Open the decimal to binary converter

Free, no sign-up, and what you enter stays in your own browser.