Decimal to Fraction Converter Formula

Understand the math behind the decimal to fraction converter. Each variable explained with a worked example.

Formulas Used

Numerator (over 1000)

numerator = round(decimal_val * 1000)

Denominator

denominator = 1000

Simplified Numerator

simplified_num = round(decimal_val * 1000) / gcd(round(abs(decimal_val * 1000)), 1000)

Simplified Denominator

simplified_den = 1000 / gcd(round(abs(decimal_val * 1000)), 1000)

Variables

VariableDescriptionDefault
decimal_valDecimal Number0.75

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.75 = 75/100) 2. Find the GCD (greatest common divisor) of the numerator and denominator 3. Divide both by the GCD to simplify

For example, 0.75 = 750/1000. GCD(750, 1000) = 250. So 750/1000 = 3/4.

Worked Example

Convert 0.75 to a fraction.

decimal_val = 0.75
  1. 010.75 = 750/1000
  2. 02GCD(750, 1000) = 250
  3. 03750 / 250 = 3
  4. 041000 / 250 = 4
  5. 050.75 = 3/4

Frequently Asked Questions

How do I convert a decimal to a fraction?

Write the decimal over a power of 10 (10, 100, 1000, etc.), then simplify by dividing numerator and denominator by their greatest common divisor.

Can all decimals be converted to fractions?

All terminating and repeating decimals can be expressed as fractions. Non-repeating, non-terminating decimals (like pi) are irrational and cannot be expressed as exact fractions.

What is 0.333... as a fraction?

0.333... (repeating) equals exactly 1/3.

Ready to run the numbers?

Open Decimal to Fraction Converter