Decimal to Fraction / Fraction to Decimal
Turn a decimal into its closest simple fraction and its exact fraction, or turn a fraction back into a repeating decimal.
Decimal to Fraction / Fraction to Decimal workspace
Converter Inputs
Continued fractions find the closest fraction within this budget, so 0.333333 becomes 1/3.
Applies to numeric results. Conversions themselves are computed at full precision.
Conversion Output
Enter a value — everything is computed in your browser.
Using Decimal to Fraction / Fraction to Decimal
Choose a direction: decimal to fraction, or fraction to decimal.
Enter the decimal value, or the numerator and denominator.
For decimals, set the largest denominator you will accept — 16 for sixteenths, 64 for fine work, or leave it at 10,000.
Read the approximation, the exact fraction from the digits you typed, the mixed number, and the error between them.
A decimal has two honest fractional answers, and both are shown: the closest fraction within your denominator budget, found by continued fractions, and the literal digits over a power of ten reduced by Euclid's algorithm. Results are echoed back as decimals with any repeating block written in brackets.
Decimal to Fraction
Turn a decimal into a fraction, or a fraction into a decimal. The interesting part is that a decimal has two honest fractional answers, and this page gives you both instead of guessing which one you wanted.
Two fractions, two different questions
Type 0.333333 and the panel shows:
- Best rational approximation — 1/3, with an approximation error of 3.333e-7
- Exact fraction from the digits entered — 333333/1000000
Neither is wrong. The first answers "what simple fraction is this decimal probably standing in for?", which is the right question when the decimal came from rounding something. The second answers "what fraction is this decimal, exactly?", which is the right question when the digits themselves are the measurement.
The two rows are produced by different methods. The exact row builds the fraction over a power of ten — 333333 over 1,000,000 — and reduces it with Euclid's greatest-common-divisor algorithm, which here divides by 1 and leaves it alone. The headline row comes from a continued-fraction expansion, walking the convergents and stopping at the last one whose denominator fits your budget. Euclid still runs, but only on the exact-from-digits row.
The denominator budget decides the answer
The budget is a dropdown, and changing it changes the result rather than just its presentation.
Leave it at 10,000 and 3.14159265 returns 355/113 with an error of 2.7e-7 — the famous approximation Chinese mathematicians had by the fifth century. Drop the budget to 16 and the same input returns 22/7, error 1.3e-3: cruder, but expressible in sixteenths.
That is what the budget is for. Set it to 16 when the answer has to be readable off a tape measure, 64 for fine woodworking, and leave it high when you want the tidiest fraction available.
Raising it too far undoes the trick. At a budget of 1,000,000, 0.333333 stops being 1/3 and becomes 333333/1000000 with zero error, because that fraction now fits and it is a closer match to the digits you typed. Larger budget, worse answer — the approximation is only useful while it is constrained.
Repeating decimals get bracket notation
The result is echoed back as a decimal with the repeating block in brackets. 1/7 is written 0.(142857), 5/6 is 0.8(3), and 7/12 is 0.58(3) — the non-repeating part sits outside the brackets.
This is long division with a memory: the remainder at each step is recorded, and when a remainder repeats, the digits between the two sightings are the cycle. It is the only notation that tells the truth about these numbers, since 0.142857142857 is a different value from 1/7 and always will be.
The expansion stops after 40 digits. A fraction with a longer period gets an ellipsis rather than brackets — 355/113 repeats with a period of 112, so it is shown truncated. The value is still exact; only the display gives up.
Signs, mixed numbers and one warning
Negatives are handled properly. -0.75 gives −3/4 and the mixed number −3/4; the previous build returned −1/1, which is not a rounding error but a different number. Values above one produce a mixed number alongside the improper fraction, so 2.5 shows as 5/2 and 2 1/2.
The warning concerns the strength of the approximation. Continued fractions are very good at finding the fraction a decimal stands in for, which means they find one whether or not it exists. Feed the golden ratio 1.6180339887 with a budget of 10,000 and you get 10946/6765 — two consecutive Fibonacci numbers, correct to nine decimal places, and still an approximation of a number with no fractional form at all. Read the error row first. When it says 0 (exact), it is; otherwise you are holding a very good guess.
Nearby number tools
- Number Base Converter — the same integers in base 2 through 36.
- Percentage Calculator — for the same ratio expressed as a percentage.
- Length Converter — pairs with the sixteenths budget for imperial measuring.
Frequently asked
Why are two different fractions shown for the same decimal?
The headline row is the closest fraction within your denominator budget, found by a continued-fraction expansion. The second is the literal digits over a power of ten, reduced with Euclid's algorithm — so 0.333333 yields both 1/3 and 333333/1000000.
What does the denominator budget change?
It caps how large a denominator the approximation may use, and it changes the answer. At 10,000 the value 3.14159265 returns 355/113; at 16 it returns 22/7, cruder but readable off a tape measure.
What do the brackets in 0.(142857) mean?
They mark the repeating block. The long division records each remainder, and when one recurs the digits between the two sightings are the cycle, so 1/7 is written 0.(142857).
Can it give an exact fraction for pi or the golden ratio?
No, and nothing can — they have no fractional form. It returns very close approximations, such as 10946/6765 for 1.6180339887, so read the approximation error row before treating a result as exact.