Advertisement

Binary fraction converter

Choose a direction, enter the fraction and set the number of binary places. The converter reports the digits, their decimal value and whether the expansion ended.

Calculator

A value from 0 up to, but not including, 1. The whole part is not converted on this page.

Between 1 and 32. A fraction that needs more places is truncated and marked.

Binary fraction
0.1011
Decimal fraction
0.687500000000
Result
Exact after 4 binary places.

Advertisement

How this calculator works

A binary fraction uses the same place-value idea as a decimal fraction, but the columns after the point are halves, quarters, eighths and so on. Each binary digit tells you whether that column is present. Converting a decimal fraction to binary works by repeatedly doubling: take the whole part of the doubled value as the next bit, keep the fractional part and repeat. If the fractional part reaches zero, the expansion is exact. Fractions whose denominator has a prime factor other than two, such as 0.1 in decimal, never terminate in binary, so the converter stops at your chosen number of places and says the result is truncated.

Formula

A binary fraction 0.b₁b₂…bₙ equals b₁/2 + b₂/4 + … + bₙ/2ⁿ. In the doubling method, start with f₀ = x. Then bᵢ = floor(2fᵢ₋₁) and fᵢ = 2fᵢ₋₁ - bᵢ. The expansion is exact when fₙ = 0.

Worked example

Start with 0.6875. Doubling gives 1.375, so the first bit is 1 and 0.375 remains. Doubling again gives 0.75, so the next bit is 0. Then 1.5 gives 1, leaving 0.5. Finally 1.0 gives 1, leaving zero. The result is 0.1011, which is 1/2 + 1/8 + 1/16 = 0.6875. Converting the digits 1011 with four places back gives the same value.

Advertisement

Frequently asked questions

Why does 0.1 not have a finite binary expansion?

In decimal, 0.1 means one tenth. Ten has a prime factor of five, which cannot be built from halves, quarters and eighths, so the binary expansion repeats forever. The converter shows as many places as you request and marks the result as truncated.

What does truncated mean here?

The displayed bits are accurate for their positions, but further bits would be needed to reach the entered decimal value exactly. Truncation always gives a binary value slightly below the original positive fraction. Adding one more place would cut the gap in half.

Can I convert a number with a whole part?

This page converts only the fractional part between 0 and 1. For a number such as 5.6875, convert the whole part 5 to 101 separately and join the results as 101.1011.

How many binary places are enough?

It depends on the precision you need. Each additional place halves the largest possible error. For a rough estimate, about 10 binary places give three decimal digits of precision, and about 20 binary places give six.

Sources

Advertisement