Advertisement

Decimal to fraction calculator

Choose an exact conversion of the displayed numeric value, or the nearest fraction within a denominator limit. Very long decimal inputs may lose digits when entered.

Calculator

Conversion uses the decimal spelling of the numeric input, normally about 15 to 17 significant digits.

Reduced fraction
3/8

Advertisement

How this calculator works

Exact conversion reads the numeric input as decimal digits over a power of ten and reduces that fraction using integer arithmetic. Nearest mode uses continued fractions to minimise the absolute error among denominators up to your limit. The input control stores a JavaScript number, so digits beyond its precision cannot be recovered.

Formula

For k decimal places, fraction = signed integer digits / 10^k, reduced by gcd. Nearest mode minimises |decimal - p/q| with 1 ≤ q ≤ maximum denominator.

Worked example

0.375 = 375/1000 = 3/8, and 2.5 = 25/10 = 5/2. With a maximum denominator of 9, the nearest fraction to 0.333333 is 1/3.

Advertisement

Frequently asked questions

Is 0.333333 exactly one third?

No. Exact conversion gives 333333/1000000. Nearest mode can choose 1/3 as a simpler approximation.

Will exact mode preserve every digit I type?

It preserves the decimal spelling of the numeric value received by the calculator. The number input may round very long entries before conversion, so this is not an arbitrary-precision text converter.

Does the maximum denominator apply in exact mode?

No. Exact mode reduces the full decimal spelling and ignores that field. The denominator limit is used only when finding the nearest fraction.

Sources

Advertisement