Decimal to Fraction Converter Formula
Understand the math behind the decimal to fraction converter. Each variable explained with a worked example.
Formulas Used
Approximate Numerator
approx_numerator = round(decimal_val * max_denom) / gcd(round(decimal_val * max_denom), max_denom)Approximate Denominator
approx_denominator = max_denom / gcd(round(decimal_val * max_denom), max_denom)Verification (decimal)
verification = (round(decimal_val * max_denom) / gcd(round(decimal_val * max_denom), max_denom)) / (max_denom / gcd(round(decimal_val * max_denom), max_denom))Variables
| Variable | Description | Default |
|---|---|---|
decimal_val | Decimal Value | 0.375 |
max_denom | Max Denominator | 1000 |
How It Works
Decimal to Fraction Converter
Method
1. Multiply the decimal by the max denominator 2. Round to the nearest integer to get the numerator 3. Use the GCD (Greatest Common Divisor) to simplify 4. Divide both numerator and denominator by the GCD
Example: 0.375 with max denominator 1000 → 375/1000 → GCD(375,1000) = 125 → 3/8
Worked Example
Convert 0.375 to a fraction.
decimal_val = 0.375max_denom = 1000
- 010.375 × 1000 = 375 (numerator before simplification)
- 02GCD(375, 1000) = 125
- 03Numerator = 375 / 125 = 3
- 04Denominator = 1000 / 125 = 8
- 05Result: 3/8
Ready to run the numbers?
Open Decimal to Fraction Converter