Math FIELD NOTES · 3 MIN READ
Decimal to Fraction: Rebuilding the Ratio Behind the Digits
How decimals become fractions again — exact place-value conversion for terminating decimals and continued-fraction best fits otherwise.
Every finite decimal is a fraction in disguise — 0.375 is 3/8 that went through a calculator and came out the other side. Converting back means recovering the ratio the digits came from, and when the digits never quite spell out an exact fraction, it means finding the best fraction that fits.
The place-value method for terminating decimals
When a decimal stops, the conversion is a matter of reading the place value off the last digit. Three digits after the point means thousandths:
0.375 = 375/1000
GCD(375, 1000) = 125
375 ÷ 125 = 3, 1000 ÷ 125 = 8 → 3/8
Write the digits over the matching power of ten, then reduce by the GCD. That final reduction is the same move a fraction simplifier makes — which is no accident, because an unreduced 375/1000 is a correct answer that just isn't finished yet. The general background on fractions as division lives in how fractions work.
Whole parts, signs, and mixed numbers
The converter handles the awkward cases a hand calculation tends to fumble. A decimal with a whole part keeps it and reports both forms: 2.625 becomes 21/8 as an improper fraction and 2 5/8 as a mixed number. A negative sign rides on the numerator: −0.6 comes back as −3/5, never as 3/−5. And a whole number is recognized immediately — 7 converts to 7/1 without any approximation machinery running at all, because an integer needs no denominators to hunt for.
Best-fit conversion for decimals that don't behave
Type 0.3333333333 and the converter answers 1/3. Strictly speaking those ten digits are the fraction 3333333333/10,000,000,000 — but 1/3 misses them by about 0.00000000003, and no fraction with a smaller denominator comes closer. The converter finds that answer with continued-fraction convergents: it repeatedly strips off the whole-number part and inverts the remainder, generating a sequence of fractions that are each the best possible approximation for their size.
0.3333333333 → 1/3 (error ≈ 3 × 10⁻¹¹)
3.14159 → 22/7 (with max denominator 100)
That second line shows the machinery's most famous hit: cap the denominator at 100 and π truncated to 3.14159 comes back as 22/7, the approximation schoolchildren have used for centuries — the convergent method rediscovers it automatically. The reverse journey, fraction to decimal with its repeating cycles, is told in fractions to decimals and back; this article is the return trip.
The max-denominator dial
The converter exposes one control: the largest denominator it's allowed to use (10,000 by default). That setting is really a simplicity-versus-accuracy dial. A tight cap produces small, friendly denominators but rounds more aggressively; a loose cap squeezes closer to the input digits at the cost of bulkier fractions. There is no single right answer — 22/7 is the right conversion for a carpenter and an insult to an astronomer — so the dial is left in your hands rather than hidden in the code.
Converter, not simplifier
It's worth separating the two jobs, since the tools look similar. The converter starts from a decimal and creates a fraction; a fraction simplifier starts from an existing fraction and reduces it. They meet at the same GCD checkpoint: the converter's final step is a reduction pass, so its output always arrives in lowest terms. Feed 0.5 to the converter or feed 50/100 to a simplifier and both hand back 1/2 — the same checkpoint, reached from opposite directions.
Try it yourself
The Decimal to Fraction Converter turns any decimal into a simplified fraction and, where one exists, a mixed number — try 0.375 for a clean 3/8, then 2.625 to see 21/8 alongside 2 5/8. Push a resulting fraction through the Fraction Simplifier to confirm it's already in lowest terms, and run the full loop with the Fraction to Decimal Converter to see digits and ratios as two views of one number.