The intuition behind decimal-to-binary conversion
A quick search for conversion methods turns up four standard techniques: two for whole numbers and two for fractional values. While knowing these methods is usually sufficient, understanding why they work can be a powerful memory aid. The second half of this article walks through the underlying arithmetic. Grabbing a pen and paper and working through the steps alongside the text is highly recommended for retention.
The four algorithms, along with worked examples, are presented below.
Whole number conversion
To convert a whole number to binary, repeatedly divide it by 2, recording both the quotient and the remainder at each stage. Keep dividing the new quotient by 2 until it reaches zero. After that, read the remainders in reverse order to get the binary representation.
Consider converting the number 12 as an example. Dividing by 2 and tracking the quotient and remainder yields:

Listing the remainders from last to first gives 1100. Therefore, the decimal 12 is written as 1100 in binary.
Fractional value conversion
For fractions, the process involves multiplying the fractional part by 2 and noting the resulting integer and fractional components. Repeat this multiplication until the fractional part becomes zero. The sequence of integer parts obtained forms the binary representation.
Let’s apply this to the fraction 0.375:

The integer parts generated at each step are 0.011. Hence, the decimal 0.375 is represented as 0.011 in binary.
Only fractions whose denominator is a power of two have a finite binary representation. Since the denominators of 0.1 (1/10) and 0.2 (1/5) are not powers of two, these numbers cannot be stored exactly in binary. They are rounded to the available mantissa bits when stored as IEEE-754 floating-point numbers — 10 bits for half-precision, 23 bits for single-precision, or 52 bits for double-precision. Depending on the precision used, the floating-point approximations of 0.1 and 0.2 may be slightly above or below their decimal counterparts, but they are never exact. Due to this, 0.1 + 0.2 will never equal 0.3.
Converting a binary whole number back to decimal
Working from the leftmost digit, take your running total, multiply it by 2, and then add the current bit. Repeat this process until every bit has been processed.
Using the binary number 1011 as an example:

Converting a binary fraction back to decimal
To decode a binary fraction, start with the rightmost bit and a total of 0. For each digit, add it to the current total and then divide the sum by 2. Continue until no digits remain. The binary fraction 0.1011 is used here as an example, with division by 2 shown as multiplication by 1/2.

Those are the four fundamental algorithms for moving between binary and decimal systems.
Expressing numbers as base‑q expansions
To understand why these methods work, we need to look at the base-q expansion of a number. Any integer can be expressed as:

where,
- N is the integer
- x is a single digit (0–9 for base-10, 0–1 for base-2)
- q is the base (10 for decimal, 2 for binary)
This form will be called the base q expansion for short. As an illustration, the number 12 can be written in both decimal and binary as:

Fractions can also be expressed in a similar way:

where,
- N is the fractional part
- x is a single digit (0–9 for base-10, 0–1 for base-2)
- q is the base (10 for decimal, 2 for binary)
For 0.375, the representations in decimal and binary are:

Whole number conversion explained
The base-q expansion provides a way to see exactly what the division algorithm does. Let’s rework the conversion of 12, but as if the binary digits were unknown. We start with an expansion containing placeholder x symbols:

The goal is now to find each x. A key observation is that every term except the last is divisible by 2, so they are all even. This means the digit x0 is determined by whether the original number is even (x0 = 0) or odd (x0 = 1). Since 12 is even, we get:

To find x1, we notice that all terms from x1 up to xN are multiples of 2. Factoring out 2 isolates something useful:

Since the value inside the parentheses is 6, our first step can be written as:

Repeating this logic, we treat the polynomial inside the parentheses as a new equation:

The same reasoning tells us x1 is 0. We can write that down and factor out 2 once more:

Our second step becomes:

At this point the pattern is clear. We keep factoring out 2 until the quotient reaches zero. Continuing with this approach:

With only one summand remaining and a quotient of 1, we reshuffle the expression:

This is the third step:

The result now reads:

Obviously x3 is 1. To fit our algorithm’s format, though, we rewrite it with an explicit quotient:

Since the quotient is now 0, nothing remains to be processed. This is the final step:

That completes the conversion. Reviewing the complete set of steps:

Each remainder lines up with one of the x placeholders: the first remainder for the first digit, the second for the next, and so on. Consequently, 12 in binary is 1100 under this method.
Recall that this derivation started from the question of why dividing by 2 works. If we move the factor of 2 to the left side of each equation, we get:

This makes it clear how the division algorithm emerges from the math. A more compact way to show all four steps together is:

It is worth ensuring you understand this representational shortcut, since it will be important when dissecting the reverse conversion.
Fractional conversion explained
The reason multiplication by 2 works for fractions is also found in the base-q expansion form. Getting back to our earlier example of 0.375, we again pretend the binary bits are unknown:

The aim is still to solve for each x. Noticing that negative powers of 2 produce fractions with denominators that are positive powers of 2, we rewrite the expansion:

Factor out 1/2 from the right-hand side of the expression:

Then move it to the other side:

At this point x1 is isolated, and it must be either 0 or 1. To decide, examine the remaining terms inside the parentheses:

Considering the maximum possible value of this sum, if we set every x to 1, we get:

This is a geometric series whose total falls within the range [0 < sum < 1]. It cannot reach 1. The relevant part of our current equation is:

Since the quantity on the right is strictly less than 1, it forces x1 to be 0 rather than 1. The remaining portion is then 0.75.

This corresponds exactly to the initial move in the algorithm:

Next, we take the fractional part, 0.75, and factor out another 1/2 to expose x2:

Move the 1/2 to the other side of the equation:

Here, if x2 is 0, the sum on the left could never reach 1.5, which is the value we have. Thus x2 must be 1, leaving 0.5 remaining.

This follows the same rhythm as the original algorithm:

Repeating the procedure with the leftover 0.5:

The same reasoning shows x3 is 1, and the fractional part is gone:

With no fractional remainder, this is the last step:

Collect all the steps together:

That is precisely the algorithm from the beginning of this discussion. Like with whole numbers, we can condense the three stages into one representation:

Make sure you are comfortable with this condensed version, because it will be a key tool in understanding how binary-to-decimal conversion works.
What prevents certain fractions from having a finite binary representation
Developers are often caught off guard by the fact that a fraction like 0.1, which terminates cleanly in decimal, never terminates in binary. This quirk sits at the very heart of the well-known floating-point surprise when 0.1 + 0.2 does not equal 0.3. The core question is: what makes a fraction representable with a finite number of digits in a given base? The full answer is nuanced. But the simplified rule is this — a fraction has a finite representation only when its denominator is a power of the base. In base 10, the denominator must be a power of 10. That’s why 0.625 has a tidy decimal form:

while 1/3 stretches out endlessly:

The identical logic governs base 2:

Now consider 0.1. Its denominator is 10, which is not a power of 2, so 0.1 becomes an endless fraction once translated into binary. Running it through the algorithm from earlier makes this visible:

The pattern repeats forever, so we can capture it as a periodic continued fraction:

Turning a binary integer into a decimal one
To demonstrate why the doubling method works, I’ll reuse the binary integer 1011 from the opening section. Once again, we lean on the base-q expansion form of the number. Here it is written out:

Since every term in the sum contains a factor of 2, we can repeatedly pull out 2 until the quotient drops to zero. Here’s that process:

If you now evaluate the expression following standard arithmetic precedence, you’ll arrive at precisely the steps shown in the earlier section:


So the binary value 1011 equals 11 in decimal.
Turning a binary fraction into a decimal one
We’ve reached the final algorithm. You may have already deduced how it works on your own. If not, here’s the reasoning. The base-q expansion form again holds the key. Let’s take 0.1011 from the first section and write it in expanded form:

Because every term carries a factor of 1/2, we can factor out 1/2 repeatedly until no fractional component remains. The procedure looks like this:

Respecting the order of operations yields the algorithm described at the start:


Hence, 0.1011 in binary translates to 0.6875 in decimal.
