Advertisement
Advertisement
DEVELOPER

Binary Fraction Converter — numbers with a point, in both directions

Convert a decimal number with a fractional part into binary and back, with every repeated-doubling step shown and the digits that repeat forever marked exactly.

Both directions are exact. The tool works in whole-number arithmetic on the numerator and denominator, so nothing is lost to rounding on the way through.
Decimal to binary accepts digits and one point, with an optional leading minus. Binary to decimal accepts 0 and 1, one point, and a repeating group in brackets such as 1010.0(0011).
Only a limit on display. If the expansion repeats, the repeating group is found and marked regardless of this figure, so the result stays exact.
How many lines of the repeated-doubling working to print underneath. Set it to zero to hide the working.
Converted value
 
 
0
Exact value as a fraction
0
Integer part in the target base
0
Fraction behaviour
0
Reduced denominator
Tip: a fraction terminates in binary only when its reduced denominator is a power of two. That single rule explains why a tenth repeats forever in binary while an eighth does not.
Advertisement

The binary fraction converter above handles the part of base conversion that most converters skip: the digits after the point. It takes a decimal value such as 10.1, converts it to binary by the repeated-doubling method, shows the working line by line, and marks the group of digits that repeats forever rather than silently truncating it. It also runs the other way, turning a binary fraction, including one with a repeating group, back into an exact decimal.

Arb Digital builds free tools with clean boundaries so that two pages never answer the same question. The live number base converter handles non-negative whole numbers across bases 2 to 36 and does not accept a decimal point. The floating point converter handles IEEE 754 storage, showing sign, exponent and mantissa bits for half, single and double precision. This page sits between them: pure positional binary fractions, of unlimited length, with no storage format involved at all.

What This Binary Fraction Converter Does

Positional notation to the right of the point works exactly as it does to the left, except that the place values divide rather than multiply. In binary the columns after the point are one half, one quarter, one eighth, one sixteenth and so on, so 0.101 in binary is a half plus an eighth, which is 0.625.

Converting the other way uses repeated doubling. Multiply the fractional part by two; the whole-number part of the result is the next binary digit, and the fraction that is left over becomes the input to the next step. When the leftover reaches zero the expansion terminates. When a leftover reappears, everything from that point repeats forever, and the tool detects that by remembering every remainder it has seen.

Because the tool works in exact whole-number arithmetic on a numerator and a denominator rather than in floating point, the repetition it reports is genuine mathematics rather than an artefact of rounding. That matters: a converter built on ordinary floating-point arithmetic cannot tell you that a tenth repeats, because it has already lost the tenth before the conversion starts.

How to Use It

  1. Choose the direction. Decimal to binary is the repeated-doubling case. Binary to decimal reads positional binary and expands it.
  2. Enter the value. A leading minus is allowed, and exactly one point. Going from binary you may also mark a repeating group in brackets, as in 1010.0(0011).
  3. Set the display limit. It caps how many digits are printed. It does not affect the detection of a repeating group, which is exact.
  4. Set how many steps to list. The working underneath shows each doubling, the digit it produced and the remainder carried forward.
  5. Read the reduced denominator. It is the single fact that decides whether the expansion terminates, and it is printed for you.

The Formula: How the Digits Are Produced

Write the fractional part as an exact fraction. A decimal input with k digits after the point is a whole number over ten to the power k, so 0.1 is one tenth and 0.375 is 375 over 1,000, which reduces to three eighths. The integer part is converted separately by repeated division, which is the ordinary whole-number algorithm.

Each binary digit then comes from one doubling. Multiply the numerator by two; if it now equals or exceeds the denominator, the digit is one and the denominator is subtracted, otherwise the digit is zero. Repeat. Every remainder is a whole number smaller than the denominator, so there are only finitely many possibilities, and the process must either reach zero or revisit a remainder it has already produced. That is why every rational number either terminates or repeats, in any base.

Work the default. The input 10.1 splits into an integer part of 10, which is 1010 in binary, and a fractional part of one tenth. Doubling gives two tenths, digit 0. Again gives four tenths, digit 0. Again gives eight tenths, digit 0. Again gives sixteen tenths, which is over one, so digit 1 with six tenths left. Again gives twelve tenths, digit 1 with two tenths left, and two tenths has appeared before. The repeat therefore starts at the second digit and the cycle is 0011, giving 1010.0(0011) in binary.

Advertisement

Why a Tenth Repeats and an Eighth Does Not

The rule is short: a fraction in lowest terms terminates in base b exactly when every prime factor of its denominator also divides b. Binary has the single prime factor two, so only denominators that are powers of two terminate. Three eighths terminates because eight is two cubed. One tenth does not, because ten is two times five, and five is not a factor of two.

The same rule explains the familiar decimal facts, since ten has the factors two and five: halves, quarters, fifths, eighths and tenths all terminate in decimal, while thirds and sevenths do not. It also explains something that surprises people the first time they meet it, which is that every terminating binary fraction terminates in decimal too. A denominator that is a power of two divides a power of ten, so the conversion from binary to decimal is always finite even though the reverse frequently is not.

The length of the repeating cycle has an equally clean description. After stripping the factors of two from the denominator, the cycle length is the multiplicative order of two modulo whatever is left. For a tenth, stripping the two leaves five, and two has order four modulo five, which is exactly the four-digit cycle 0011 the tool reports.

What This Has To Do With Floating-Point Bugs

The reason 0.1 plus 0.2 does not equal 0.3 in almost every programming language is precisely the repetition shown above. A double stores a finite number of binary digits, so an infinitely repeating expansion has to be cut off and rounded, and the stored value is a little more or a little less than the decimal you typed. Two such errors added together need not match the rounding of the third.

David Goldberg's What Every Computer Scientist Should Know About Floating-Point Arithmetic is the standard treatment of what follows from that, and Thomas Finley's Floating Point notes for CPS 104 walk through the same repeated-multiplication algorithm this page implements before applying it to a mantissa.

The practical consequence is a rule of thumb worth internalising. If a value must be represented exactly, either keep it as an integer in the smallest unit, such as cents rather than dollars, or use a decimal type that stores base-ten digits. Binary floating point is excellent at approximate arithmetic over a huge range and is simply the wrong container for exact decimal quantities. Seeing the repeating group here makes that concrete in a way that a warning in a manual does not.

Repeating Notation, and Reading It Back

The bracket notation used here writes the non-repeating digits first and the repeating group in brackets, so 1010.0(0011) means the digits 0011 continue without end after the initial 0. Other conventions put a bar over the group or a dot at each end; they mean the same thing, and the tool accepts the bracket form on input.

Reading such a value back to decimal is exact rather than approximate. A repeating group of q digits starting after p non-repeating digits corresponds to a denominator of two to the power p, multiplied by two to the power q minus one. That is a finite fraction, and expanding it in base ten either terminates or repeats by the same rule as before, so the tool can report an exact answer rather than a truncated one.

How This Page Sits Beside the Other Conversion Tools

The boundary in one sentence: the number base converter converts whole numbers between bases, the floating point converter shows how a value is stored in IEEE 754 bits, and this page converts the fractional part itself, exactly and to any length, with no storage format in the way.

For arithmetic on binary values, the binary arithmetic calculator adds and subtracts them and the bitwise calculator applies logical operations. The scientific notation converter handles very large and very small decimals, the significant figures calculator keeps reported precision honest, and the baud rate calculator uses fractional divisors of exactly the kind this page expands.

Need a website that loads fast and actually works?

Arb Digital builds free tools like this one because useful pages earn attention. If you want tools, calculators or content built for your own audience, we can help.

See Our Web Design Work Talk to Arb Digital

Common Mistakes to Avoid

  • Treating a truncated expansion as exact — a converter that stops after sixteen digits without saying so has given you a different number from the one you entered.
  • Dividing the fractional part instead of doubling it — the integer part uses repeated division, the fractional part uses repeated multiplication, and swapping them is the classic exam slip.
  • Reading the digits in the wrong order — fractional digits come out in the order they are produced, unlike integer digits, which come out backwards and must be reversed.
  • Assuming a decimal that looks simple is simple in binary — 0.1, 0.2 and 0.3 all repeat forever, while 0.5, 0.25 and 0.125 do not.
  • Using floating point to test for repetition — the rounding happens before you look, so the answer has to come from exact whole-number arithmetic.

Related Free Tools From Arb Digital

Convert whole numbers with the number base converter, inspect stored values with the floating point converter, and work on binary values with the binary arithmetic calculator and the bitwise calculator. The scientific notation converter and significant figures calculator handle decimal precision, the baud rate calculator applies fractional division to clock dividers, and the full free online tools hub has everything else.

Frequently Asked Questions

How is this different from the number base converter?

The number base converter handles non-negative whole numbers across bases 2 to 36 and does not accept a decimal point. This page is only about the digits after the point, in binary, and it reports repeating expansions exactly rather than truncating them.

How is it different from the floating point converter?

The floating point converter shows how a value is stored in IEEE 754, with sign, exponent and mantissa bits and the rounding error that storage introduces. This page has no storage format at all: it produces the mathematically exact positional expansion, however long it runs.

Why does 0.1 repeat in binary?

Because a fraction terminates in a base only when every prime factor of its reduced denominator divides that base. A tenth reduces to one over ten, and ten has the factor five, which does not divide two. The expansion is 0.0(0011), with the four digits 0011 repeating forever.

Which decimal fractions do terminate in binary?

Exactly those whose reduced denominator is a power of two: halves, quarters, eighths, sixteenths and so on. So 0.5, 0.25, 0.125 and 0.375 all terminate, while 0.1, 0.2 and 0.3 do not.

Does every binary fraction terminate in decimal?

Yes. A denominator that is a power of two divides a power of ten, so the decimal expansion always ends. That is why the binary-to-decimal direction is finite even when the decimal-to-binary direction is not.

How long can the repeating group be?

After removing the factors of two from the denominator, the cycle length is the multiplicative order of two modulo what remains. It can be long: a denominator with a large prime factor can produce a cycle of hundreds of digits, which is why the tool finds the cycle rather than guessing at it.

What does the bracket notation mean?

The digits inside the brackets repeat without end. In 1010.0(0011) the leading 0 appears once and the group 0011 continues forever. Other conventions use an overbar or dots, and they all mean the same thing.

Is the conversion exact or rounded?

Exact. The tool works on a whole-number numerator and denominator throughout, so the digits and the repeating group are mathematically correct. The display limit only controls how many digits are printed, not how they are computed.

Advertisement
Advertisement

Take it further