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

Ready to run the numbers?

Open Decimal to Fraction Converter