Everyday Life · General Mathematics
Decimal to Fraction Calculator
Converts any decimal number into its simplest fraction form by finding the greatest common divisor of the numerator and denominator.
Calculator
Formula
Where d is the original decimal, n is the number of decimal places, p is the resulting numerator, q is the resulting denominator, and gcd is the greatest common divisor of p and q. Multiplying the decimal by 10^n converts it to an integer, then dividing both numerator and denominator by their GCD reduces the fraction to its simplest form.
Source: Elementary Number Theory — standard GCD reduction method as described in Hardy & Wright, An Introduction to the Theory of Numbers, Oxford University Press.
How it works
Every finite decimal can be expressed as a fraction with a power of ten in the denominator. For example, 0.75 has two decimal places, so it equals 75/100. The key challenge is then simplifying this fraction to its lowest terms — and that is where the Greatest Common Divisor (GCD) comes in. The GCD of two integers is the largest number that divides both of them without leaving a remainder.
The algorithm works in three steps. First, count the number of decimal places (n) in the input. Second, multiply the decimal by 10^n to obtain an integer numerator, while setting the denominator to 10^n. Third, compute the GCD of the numerator and denominator using the Euclidean algorithm — one of the oldest and most efficient algorithms in mathematics — and divide both by it. The result is the fraction in its simplest, fully-reduced form. For example, 0.75 becomes 75/100, and since gcd(75, 100) = 25, this reduces to 3/4.
This method is used in everyday contexts from woodworking and cooking measurements (where fractions of an inch or cup are standard) to financial calculations and academic mathematics. Understanding the relationship between decimals and fractions also deepens number sense and is a core component of school-level mathematics curricula worldwide.
Worked example
Example 1: Convert 0.625 to a fraction
Step 1: Count decimal places — 0.625 has 3 decimal places, so n = 3.
Step 2: Multiply by 10^3 = 1000: numerator = 625, denominator = 1000.
Step 3: Find gcd(625, 1000). Using the Euclidean algorithm: 1000 = 1 × 625 + 375 → 625 = 1 × 375 + 250 → 375 = 1 × 250 + 125 → 250 = 2 × 125 + 0. So gcd = 125.
Step 4: Divide: 625 ÷ 125 = 5, 1000 ÷ 125 = 8. Result: 5/8.
Example 2: Convert 1.2 to a fraction
Step 1: 1 decimal place, so n = 1.
Step 2: 1.2 × 10 = 12; denominator = 10.
Step 3: gcd(12, 10) = 2.
Step 4: 12 ÷ 2 = 6, 10 ÷ 2 = 5. Result: 6/5, or equivalently the mixed number 1 and 1/5.
Limitations & notes
This calculator works precisely for terminating decimals — those with a finite number of decimal places. It does not handle repeating (recurring) decimals such as 0.333... or 0.142857... which require a separate algebraic method (multiplying by powers of 10 and subtracting). Very long decimals may introduce floating-point rounding errors inherent to JavaScript number representation, so extremely precise inputs (more than 10–12 significant figures) may not convert perfectly. Additionally, irrational numbers such as π (3.14159...) or √2 (1.41421...) cannot be expressed as exact fractions at all — any fractional result for these inputs is only an approximation based on the digits entered.
Frequently asked questions
How do I convert a decimal to a fraction manually?
Write the decimal over 1, then multiply both numerator and denominator by 10 for each digit after the decimal point. For example, 0.4 = 4/10. Then simplify by dividing both by their greatest common divisor — here gcd(4,10) = 2, giving 2/5.
Can this calculator convert repeating decimals like 0.333... to fractions?
No — this calculator is designed for terminating decimals only. Repeating decimals require an algebraic approach: let x = 0.333..., then 10x = 3.333..., subtract to get 9x = 3, so x = 1/3. A dedicated repeating decimal converter would be needed for those cases.
Why does 0.1 + 0.2 not equal 0.3 exactly in computers?
Floating-point arithmetic in binary cannot represent certain decimals (like 0.1 or 0.2) exactly. This is a fundamental limitation of the IEEE 754 standard used by virtually all modern processors. For this reason, very long decimal inputs may yield slightly imprecise fractions in this calculator.
What is the difference between a proper fraction, improper fraction, and mixed number?
A proper fraction has a numerator smaller than the denominator (e.g. 3/4). An improper fraction has a numerator equal to or larger than the denominator (e.g. 5/4). A mixed number combines a whole number with a proper fraction (e.g. 1 and 1/4). They all represent the same value in different notations.
Why do engineers and carpenters prefer fractions over decimals?
Imperial measuring tools (rulers, tape measures) are graduated in fractions of an inch — typically halves, quarters, eighths, and sixteenths. Converting a decimal measurement such as 0.375 inches to 3/8 inch allows direct reading of a physical ruler without rounding errors, making fractions the practical standard in construction, machining, and woodworking in the United States and UK.
Last updated: 2025-01-15 · Formula verified against primary sources.