DecimalBinary

Whole numbers, fractions and negatives

Try
BinaryExact
1010.101
4 integer bits · 3 fraction bits

Integer part

Divide by 2, keep the remainders
DivideQuotientRemainder
10 ÷ 250
5 ÷ 221
2 ÷ 210
1 ÷ 201

Remainders, bottom to top: 1010

Fraction part

Multiply by 2, keep the whole parts
MultiplyResultBit
0.625 × 21.251
0.25 × 20.50
0.5 × 211

Bits, top to bottom: 101. The fraction reached 0, so the result is exact.

Guide

How to convert decimal to binary

  1. Set the sign aside and split the number at the decimal point. 10.625 becomes 10 and 0.625.
  2. Convert the whole part by dividing by 2 again and again. The remainders, read from bottom to top, are its bits.
  3. Convert the fraction by multiplying by 2 again and again. Each time, the digit before the point (0 or 1) is the next bit, and you carry on with what's after the point.
  4. Write the two parts with a binary point between them. Put the minus sign back for negative numbers.

Worked example

Converting 10.625. First the whole part, 10:

DivideQuotientRemainder
10 ÷ 250
5 ÷ 221
2 ÷ 210
1 ÷ 201

Then the fraction, 0.625:

MultiplyResultBit
0.625 × 21.251
0.25 × 20.50
0.5 × 211

10.625 → 1010.101

  • Only fractions with a power of 2 below the line end in binary. 0.5, 0.25 and 0.375 are exact, but 0.1 repeats forever as 0.0001100110011…
  • That's why 0.1 + 0.2 isn't exactly 0.3 in most programming languages: neither number fits exactly in binary.
  • Negative numbers get a minus sign here. To see how a computer stores them, use Two's Complement.
Learn

Understanding decimal to binary conversion

Two ways to convert whole numbers, how fractions work, and why some never end in binary.

Computers store every number in base 2, and a decimal to binary converter rewrites an everyday base-10 number that way, using only the digits 0 and 1. This one goes beyond whole numbers: it converts fractions and negative numbers too, keeps very large values exact, and shows every step of the working. Below you'll find two ways to convert decimal to binary by hand, how fractions work, and why some numbers never come out exact.

Decimal and binary place values

In decimal, each position is worth ten times the one to its right: ones, tens, hundreds, thousands. Binary works the same way, but each position is worth twice the one to its right: 1, 2, 4, 8, 16, 32, 64, 128 and so on. Converting decimal to binary means finding which of those powers of two add up to your number. Because every power of two is used at most once, each binary digit is simply 1 if that power is included and 0 if it isn't.

Method 1: repeated division by 2

The method this converter shows is the most reliable for any size of number. Divide by 2, write down the remainder (0 or 1), and repeat with the quotient until it reaches 0. Then read the remainders from the last one to the first. Here's 156:

DivideQuotientRemainder
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Reading the remainders from bottom to top gives 10011100, so 156 in binary is 10011100.

Method 2: subtracting powers of two

For smaller numbers, many people find it faster to work from the largest power of two downward. Find the biggest power of two that fits, subtract it, and repeat with what's left. For 156, the biggest power that fits is 128, leaving 28. Then 16 fits, leaving 12, then 8, leaving 4, then 4, leaving 0. So 156 = 128 + 16 + 8 + 4. Put a 1 under each power you used and a 0 under the rest, and you get the same answer: 10011100. Both methods always agree, so you can use one to check the other.

Converting decimal fractions to binary

The part after the decimal point is converted by multiplying instead of dividing. Multiply the fraction by 2. If the result is 1 or more, the next binary digit is 1 and you carry on with what's after the point. If it's less than 1, the next digit is 0. For 0.375: 0.375 × 2 = 0.75 gives 0, 0.75 × 2 = 1.5 gives 1, and 0.5 × 2 = 1 gives 1 with nothing left over. Reading the digits from top to bottom gives 0.011. Combine that with the whole-number part, and a number like 10.625 becomes 1010.101.

Why 0.1 never ends in binary

A fraction only ends in binary if its denominator, in lowest terms, is a power of 2. That's why 0.5, 0.25 and 0.375 convert exactly, while 0.1, which is 1/10, repeats forever as 0.0 followed by 0011 over and over. This converter detects repeating patterns, marks the repeating bits and shows the exact value of the bits it displays. It's also the reason computers can't store 0.1 exactly: a standard double-precision number keeps only 53 significant bits, so 0.1 + 0.2 comes out as 0.30000000000000004 in JavaScript and many other languages.

Negative decimal numbers

Mathematically, converting a negative decimal to binary just means converting its size and keeping the minus sign: −13 becomes −1101. That's what this tool shows. Computers, however, usually store negative whole numbers in a fixed number of bits using two's complement, where −13 in 8 bits is 11110011. If you need that stored bit pattern, use the two's complement calculator.

Large numbers stay exact

Many online converters quietly round large numbers because they rely on ordinary floating-point arithmetic, which is exact only up to 9,007,199,254,740,991 in JavaScript. This decimal to binary converter uses arbitrary-precision integers instead, so a number like 18,446,744,073,709,551,616 (2⁶⁴) converts exactly to a 1 followed by 64 zeros. You can paste numbers up to 120 characters long, and you can type spaces or underscores to group digits.

Tips for converting decimal to binary

  • Use a dot for the decimal point and leave out thousands separators such as commas.
  • Choose 8, 16, 32 or 64 fraction bits to control how much of a long fraction is shown.
  • Turn on Group by 4 to make long results easier to read, or convert them to hex with the binary to hex converter.
  • Check any result in reverse with the binary to decimal converter, which gives the exact value back.

Worth remembering: a fraction converts exactly only when its denominator, in lowest terms, is a power of two. That's why 0.5 and 0.375 end in binary, while 0.1 and 0.2 repeat forever.

FAQ

Frequently asked questions

Quick answers about the decimal to binary converter and how it works.

How do I convert a decimal number to binary?

For the whole part, divide by 2 repeatedly and read the remainders from bottom to top. For the fraction, multiply by 2 repeatedly and read the whole parts from top to bottom. The tool shows both tables for whatever you type.

For example, 10.625 is 1010.101.

How are negative numbers converted?

The result keeps the minus sign, so -13 becomes -1101. That's the mathematical answer.

Computers usually store negative numbers in two's complement instead, where −13 in 8 bits is 11110011. Use Two's Complement for that.

Why doesn't 0.1 convert exactly?

In binary, 0.1 never ends. It's 0.0 followed by 0011 repeating forever. Only fractions whose denominator is a power of 2, such as 0.5, 0.25 and 0.375, end in binary.

The tool spots repeating patterns, marks the repeating bits with a line and shows the exact value of the bits it displays. It's also why 0.1 + 0.2 isn't exactly 0.3 in most programming languages.

How many bits after the binary point are shown?

Pick 8, 16, 32 or 64 fraction bits from the menu. Exact results stop early. Longer ones are cut off at that length, not rounded, and marked as cut off or repeating.

How large a number can I convert?

The whole-number part is converted exactly, however large it is, up to an input of 120 characters. There's no rounding and no floating-point error.

Can I type commas or spaces in the number?

Use a dot for the decimal point and leave out thousands separators such as commas. Spaces and underscores are ignored, so 1 000 000 and 1_000_000 both work.

Still have a question?Contact us