Decimal to Fraction Calculator Formula
Understand the math behind the decimal to fraction calculator. Each variable explained with a worked example.
Formulas Used
Numerator
numerator = round(decimal_val * 10000) / gcd(abs(round(decimal_val * 10000)), 10000)Denominator
denominator = 10000 / gcd(abs(round(decimal_val * 10000)), 10000)Verification
verification = (round(decimal_val * 10000) / gcd(abs(round(decimal_val * 10000)), 10000)) / (10000 / gcd(abs(round(decimal_val * 10000)), 10000))Variables
| Variable | Description | Default |
|---|---|---|
decimal_val | Decimal Value | 0.375 |
raw_numerator | Derived value= round(decimal_val * 10000) | calculated |
raw_denominator | Derived value= 10000 | calculated |
common_factor | Derived value= gcd(abs(round(decimal_val * 10000)), 10000) | calculated |
How It Works
How to Convert a Decimal to a Fraction
Method
1. Write the decimal as a fraction over a power of 10 (e.g., 0.375 = 375/1000) 2. Simplify by dividing both numerator and denominator by their GCD 3. For example: 375/1000 → GCD(375, 1000) = 125 → 375/125 = 3, 1000/125 = 8 → 3/8
This calculator uses a denominator of 10,000 for precision and then simplifies.
Worked Example
Convert 0.375 to a fraction.
- 010.375 × 10000 = 3750
- 02Fraction = 3750/10000
- 03GCD(3750, 10000) = 1250
- 04Simplified: 3750/1250 = 3, 10000/1250 = 8
- 05Result: 3/8
Frequently Asked Questions
How do you convert a decimal to a fraction?
Multiply the decimal by a power of 10 to remove the decimal point, then simplify the resulting fraction by dividing numerator and denominator by their greatest common factor.
Can every decimal be expressed as a fraction?
Every terminating decimal and every repeating decimal can be expressed as a fraction. However, irrational numbers like pi or sqrt(2) cannot be expressed as exact fractions.
Learn More
Guide
Understanding Fractions and Decimals - Complete Guide
Learn how fractions and decimals work, how to convert between them, and how to perform arithmetic operations. Includes simplification, comparison, and practical tips.
Ready to run the numbers?
Open Decimal to Fraction Calculator