Skip to content
Math & Statisticsfractions

Decimal to Fraction Calculator

A decimal as its simplest fraction. Terminating decimals convert exactly; anything else gets the best rational approximation within the denominator you allow.

Also called: decimal to fraction, convert decimal.

As a fraction
3/8

0.38 is 3/8, which is 0.38 as a decimal. That is exact.

Numerator
3
Denominator
8
The fraction back as a decimal
0.38
Difference from your input
0
On accuracy
That is exact.
Method and background

How this is calculated

A terminating decimal is already a fraction over a power of ten and simply needs reducing. Anything else is approximated, and the method matters: a Stern-Brocot search finds the fraction with the smallest denominator within your bound that is closest to the value, which is why pi comes out as 355/113 rather than something with far more digits and no better accuracy.

the best rational approximation within a denominator bound, found by binary search on the Stern-Brocot tree
x
The decimal
q
Denominator, bounded

Worked examples

Each of these is asserted on every build. If a change to the engine ever moved one of these answers, the build would fail before the page could print it.

three eighths

Decimal
0.38
Largest denominator to allow
10,000

As a fraction3/8

A terminating decimal converts exactly

Open this example

a repeating decimal approximates

Decimal
0.33
Largest denominator to allow
10,000

As a fraction1/3

boundary: the Stern-Brocot search finding the simple answer

Open this example

a whole number is over one

Decimal
5
Largest denominator to allow
10,000

As a fraction5

degenerate case

Open this example

Method and limits

What it assumes

  • The bound on the denominator is yours to set.

What it deliberately does not model

  • A very tight bound produces a visibly inaccurate fraction, which the error figure exposes.

Formula version 1.0.0 · definition 1.0.0 · India · Report a problem with this calculator

Frequently asked questions

Why not just use the digits over a power of ten?
It works for terminating decimals and reduces badly for anything else. 0.333333 over a million reduces to something unhelpful, while a Stern-Brocot search returns 1/3.