StatGardenREF. DESK
Calculators/Maths/Decimal ↔ fraction
Maths

Decimal ↔ fraction calculator

Closest fraction to a decimal, at a chosen precision.

What this calculator does

Every terminating decimal can be written as an exact fraction, and every repeating decimal can too. But the exact fraction is often unwieldy: 0.142857 is close to 1/7, yet writing it exactly gives 142857/1000000, which tells you nothing useful.

This calculator finds the best approximation at whatever denominator limit you set, using continued fraction expansion. That method produces the closest fraction available for a given size of denominator, which is why it turns 3.14159 into 355/113 rather than something less elegant.

The formula

FormulaContinued-fraction expansion of the decimal, stopping when the denominator exceeds the limit

Continued fraction expansion repeatedly takes the integer part of a number, then inverts the remainder and repeats. The convergents produced along the way are provably the best rational approximations for their denominator size, which is why the method beats simply rounding.

TermMeaning
ConvergentA successive approximation from the continued fraction expansion.
Denominator limitThe largest denominator you will accept.
ErrorThe gap between the decimal and the fraction found.

The inputs explained

FieldWhat to enter
DecimalThe decimal to convert.
Largest denominator allowedThe largest denominator allowed. Lower limits give simpler but less accurate fractions; higher limits give closer ones.

When to use it

Converting a measurement

Decimal readings often need expressing in imperial fractions. Set the limit to 16 or 32 for measurements that must fall on tape-measure divisions.

Finding an elegant approximation

Set a modest limit and see what appears. Many constants have famously neat approximations: 22/7 and 355/113 for pi are the classic examples.

Recognising a repeating decimal

If a decimal came from a fraction originally, this usually recovers it. 0.375 returns 3/8, and 0.8333 returns 5/6.

Simplifying for communication

Three-quarters is easier to hold in mind than 0.75, and much easier than 0.7482. A rounded fraction is often the more useful figure to quote.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

Common decimals as fractions

A range of decimals converted at a generous denominator limit.

Denominator limit 1000
DecimalFractionCheckError
0.1251/80.12500
0.333333/10000.33300
0.3753/80.37500
0.6255/80.62500
0.83335/60.83330.000033
3.14159355/1133.1420.000003
3.14159 returns 355/113, an approximation to pi known since the fifth century and among the best available for so small a denominator. The error column shows how close each approximation lands.

How the denominator limit changes the answer

The same decimal at different denominator limits.

Converting 0.4285714
Denominator limitFractionCheckError
up to 52/50.40000.0286
up to 103/70.42862.8571e-8
up to 503/70.42862.8571e-8
up to 1003/70.42862.8571e-8
up to 10003/70.42862.8571e-8
up to 100003/70.42862.8571e-8
Tighter limits force simpler fractions with larger errors. This decimal is very close to 3/7, which the method finds as soon as the limit allows a denominator of seven.

Questions

How do I convert a decimal to a fraction by hand?

For a terminating decimal, write the digits over the matching power of ten and simplify: 0.375 becomes 375/1000, which reduces to 3/8. Repeating decimals need an algebraic method involving multiplying by a power of ten and subtracting.

Why does the calculator give an approximation?

Because you set a denominator limit. Within that limit, continued fraction expansion finds the closest fraction available. Raise the limit and the error falls.

What is a continued fraction?

A way of writing a number as an integer plus one over another integer plus one over another, continuing on. Truncating it at any point gives the best rational approximation for that denominator size.

Can every decimal be written as a fraction?

Every terminating or repeating decimal can. Irrational numbers such as pi and the square root of two cannot be written exactly as any fraction: only approximated, which is what this does.

What denominator limit should I use?

It depends on the purpose. Use 16 or 32 for imperial measurement, 100 for a readable everyday fraction, and higher when accuracy matters more than simplicity.

To calculate with the resulting fractions, use the fraction calculator. For rounding decimals instead, see rounding and significant figures.