TExcelTAD
Home › Basic Math & Pre-Algebra › Fractions, Decimals and Percents

Fractions, Decimals and Percents

Fractions, decimals and percents are three ways to write the same number: 34=0.75=75%\frac{3}{4} = 0.75 = 75\%. This lesson collects all six conversions in one place, gives a table of values worth knowing by heart, and shows Python's conversion tools, including how to recover a simple fraction from a messy float.

The six conversions

text
            ÷ (top by bottom)            × 100, add %
 fraction ────────────────────► decimal ───────────────► percent
          ◄────────────────────         ◄───────────────
          write over 10, 100, …         ÷ 100, drop %
          and simplify
From → To How Example
fraction → decimal divide numerator by denominator 38=3÷8=0.375\frac{3}{8} = 3 \div 8 = 0.375
decimal → percent multiply by 100 (point 2 places right) 0.375=37.5%0.375 = 37.5\%
percent → decimal divide by 100 (point 2 places left) 6.5%=0.0656.5\% = 0.065
decimal → fraction write over a power of 10, simplify 0.065=651000=132000.065 = \frac{65}{1000} = \frac{13}{200}
fraction → percent fraction → decimal → percent 25=0.4=40%\frac{2}{5} = 0.4 = 40\%
percent → fraction write over 100, simplify 85%=85100=172085\% = \frac{85}{100} = \frac{17}{20}

Tip: For fraction → percent with a "nice" denominator, scale to 100 directly: 720=35100=35%\frac{7}{20} = \frac{35}{100} = 35\%, 325=12100=12%\frac{3}{25} = \frac{12}{100} = 12\%.

Values worth memorising

Fraction Decimal Percent
12\frac{1}{2} 0.5 50%
13\frac{1}{3} 0.333…0.333\ldots 3313%33\frac{1}{3}\%
23\frac{2}{3} 0.666…0.666\ldots 6623%66\frac{2}{3}\%
14\frac{1}{4} 0.25 25%
34\frac{3}{4} 0.75 75%
15\frac{1}{5} 0.2 20%
16\frac{1}{6} 0.1666…0.1666\ldots 1623%16\frac{2}{3}\%
18\frac{1}{8} 0.125 12.5%
38\frac{3}{8} 0.375 37.5%
110\frac{1}{10} 0.1 10%
120\frac{1}{20} 0.05 5%
1100\frac{1}{100} 0.01 1%

From these you can build others: 58=12+18=62.5%\frac{5}{8} = \frac{1}{2} + \frac{1}{8} = 62.5\%, and 78=1−18=87.5%\frac{7}{8} = 1 - \frac{1}{8} = 87.5\%.

Repeating decimals and percents

Fractions whose denominator has prime factors other than 2 and 5 give repeating decimals. You can write the percent exactly as a mixed number (13=3313%\frac{1}{3} = 33\frac{1}{3}\%) or round it (33.3%). Rounding loses information, so convert at the very end, for display.

Conversions in Python

python · try it yourself
from fractions import Fraction
from decimal import Decimal

f = Fraction(3, 8)
print("fraction -> decimal:", float(f), Decimal(f.numerator) / Decimal(f.denominator))
print("fraction -> percent:", f"{float(f):.1%}")

print("percent -> fraction:", Fraction(85, 100), " ", Fraction("6.5") / 100)
print("decimal -> fraction:", Fraction("0.065"), " ", Fraction(Decimal("0.375")))

for text in ["2/5", "7/20", "1/3", "5/6"]:
    x = Fraction(text)
    print(f"{text:>5} = {float(x):.4f} = {float(x):.2%}")
fraction -> decimal: 0.375 0.375
fraction -> percent: 37.5%
percent -> fraction: 17/20   13/200
decimal -> fraction: 13/200   3/8
  2/5 = 0.4000 = 40.00%
 7/20 = 0.3500 = 35.00%
  1/3 = 0.3333 = 33.33%
  5/6 = 0.8333 = 83.33%

From a float back to a fraction

A float is stored in binary, so converting it to a fraction directly gives its exact binary value, which is usually ugly. limit_denominator(n) finds the closest fraction with a denominator of at most nn, which recovers the "intended" fraction:

python · try it yourself
from fractions import Fraction

x = 0.1
print(Fraction(x))                         # exact binary value of the float
print(Fraction(x).limit_denominator(1000))

ratio = 1920 / 1080                        # an aspect ratio as a float
print(ratio, "->", Fraction(ratio).limit_denominator(100))

print(Fraction(3.14159265).limit_denominator(10))     # a famous approximation of π
print(Fraction(3.14159265).limit_denominator(1000))
3602879701896397/36028797018963968
1/10
1.7777777777777777 -> 16/9
22/7
355/113

227\frac{22}{7} and 355113\frac{355}{113} are the best fractions for π\pi with small denominators; 355113\frac{355}{113} is right to six decimal places.

In software

  • Storage vs display: store rates as decimals or exact fractions (0.075, Fraction(3, 40)), show them as percents (7.5%). Never store the display string.
  • APIs and units: one API sends "discount": 15 (percent), another "discount": 0.15 (fraction). Mixing them up gives a discount 100 times too big or too small. Name fields clearly (discount_pct, discount_rate).
  • Parsing user input: a form that accepts "1/2", "0.5" or "50%" can normalise all three to a Fraction.

Exercises

Exercise 1: Fill the table

Convert 35\frac{3}{5} to a decimal and percent, 0.125 to a fraction and percent, and 140% to a decimal and fraction.

Answer

35=0.6=60%\frac{3}{5} = 0.6 = 60\%; 0.125=18=12.5%0.125 = \frac{1}{8} = 12.5\%; 140%=1.4=75140\% = 1.4 = \frac{7}{5}.

Solution
35=610=0.6→×100→60%0.125=1251000=18,0.125×100=12.5%140%=140100=1.4=75 (=125)\begin{aligned} \frac{3}{5} &= \frac{6}{10} = 0.6 \to \times 100 \to 60\% \\ 0.125 &= \frac{125}{1000} = \frac{1}{8},\quad 0.125 \times 100 = 12.5\% \\ 140\% &= \frac{140}{100} = 1.4 = \frac{7}{5}\ (= 1\tfrac{2}{5}) \end{aligned}

Exercise 2: Percent with a repeating part

Write 5/12 as a percent, exactly (as a mixed number) and rounded to one decimal place.

Answer

4123%≈41.7%41\frac{2}{3}\% \approx 41.7\%

Solution

512×100%=50012%=1253%=4123%\frac{5}{12} \times 100\% = \frac{500}{12}\% = \frac{125}{3}\% = 41\frac{2}{3}\%. As a decimal 41.666…%41.666\ldots\%, which rounds to 41.7%.

Exercise 3: Order mixed forms

Order from smallest to largest: 0.62, 58\frac{5}{8}, 61%, 35\frac{3}{5}.

Answer

35<61%<0.62<58\frac{3}{5} < 61\% < 0.62 < \frac{5}{8}

Solution

Convert all to decimals: 0.62, 0.625, 0.61, 0.6. Sorted: 0.6<0.61<0.62<0.6250.6 < 0.61 < 0.62 < 0.625.

Exercise 4: A forgiving parser

Write parse(text) that accepts "1/2", "0.5", "50%" or "12.5%" and returns a Fraction. Test it on "3/8", "0.375", "37.5%" and "150%".

Answer

38\frac{3}{8}, 38\frac{3}{8}, 38\frac{3}{8} and 32\frac{3}{2}.

Solution

A trailing % means "divide by 100". Fraction already understands "3/8" and "0.375".

python · try it yourself
from fractions import Fraction

def parse(text):
    text = text.strip()
    if text.endswith("%"):
        return Fraction(text[:-1]) / 100
    return Fraction(text)

for t in ["3/8", "0.375", "37.5%", "150%"]:
    print(t, "->", parse(t))
3/8 -> 3/8
0.375 -> 3/8
37.5% -> 3/8
150% -> 3/2

Test yourself

What is 78\frac{7}{8} as a percent?

  1. 78%
  2. 8.75%
  3. 87.5%
  4. 0.875%

What is 0.4% as a decimal?

  1. 0.4
  2. 0.04
  3. 0.004
  4. 4

What does Fraction(0.25) give?

  1. 1/4
  2. a huge fraction
  3. 25/100
  4. an error