DEV Community

Michael Lip
Michael Lip

Posted on • Originally published at zovo.one

Fraction Arithmetic Is Harder Than You Remember. Let a Machine Do It.

Ask most adults to add 3/7 and 5/11 without a calculator and watch them pause. Fraction arithmetic is one of those skills that fades fast after school, and when you need it -- for woodworking measurements, recipe scaling, engineering calculations, or implementing rational number libraries -- the rules feel less intuitive than you remember.

I want to refresh the fundamentals and explain why fractions still matter in a world of floating-point decimals.

Why fractions exist when we have decimals

The number 1/3 in decimal is 0.333333... repeating forever. No finite decimal representation is exact. In a programming context, this means floating-point arithmetic produces tiny errors that accumulate:

0.1 + 0.2 === 0.3  // false
0.1 + 0.2          // 0.30000000000000004
Enter fullscreen mode Exit fullscreen mode

Fractions avoid this entirely. 1/3 + 1/3 + 1/3 = 3/3 = 1, exactly. No rounding, no accumulated error.

Financial calculations, scientific computing, and any domain where exact arithmetic matters either uses fractions (rational numbers) internally or uses decimal libraries that avoid binary floating-point. The fraction representation 1/10 is exact; the IEEE 754 binary representation of 0.1 is an infinite repeating binary that gets truncated.

The four operations refresher

Addition and subtraction require a common denominator:

a/b + c/d = (a*d + c*b) / (b*d)
3/7 + 5/11 = (3*11 + 5*7) / (7*11) = (33 + 35) / 77 = 68/77
Enter fullscreen mode Exit fullscreen mode

Finding the least common denominator (LCD) instead of just multiplying denominators keeps numbers smaller. The LCD of 7 and 11 is 77 (they are coprime), but the LCD of 4 and 6 is 12, not 24.

Multiplication is the simple one:

a/b * c/d = (a*c) / (b*d)
3/7 * 5/11 = 15/77
Enter fullscreen mode Exit fullscreen mode

Division flips the second fraction and multiplies:

a/b / c/d = a/b * d/c = (a*d) / (b*c)
3/7 / 5/11 = 3/7 * 11/5 = 33/35
Enter fullscreen mode Exit fullscreen mode

Simplification using GCD

After every operation, you should simplify the result by dividing both numerator and denominator by their greatest common divisor.

function gcd(a, b) {
  a = Math.abs(a);
  b = Math.abs(b);
  while (b) {
    [a, b] = [b, a % b];
  }
  return a;
}

function simplify(num, den) {
  const g = gcd(num, den);
  return [num / g, den / g];
}
Enter fullscreen mode Exit fullscreen mode

68/77 is already simplified (GCD of 68 and 77 is 1). But 24/36 simplifies to 2/3 (GCD is 12).

Mixed numbers and improper fractions

A mixed number like 2 3/4 is really 2 + 3/4 = 11/4. Converting between mixed numbers and improper fractions:

Mixed to improper: whole * denominator + numerator / denominator
2 3/4 = (2*4 + 3) / 4 = 11/4

Improper to mixed: quotient remainder/divisor
11/4 = 2 remainder 3 = 2 3/4
Enter fullscreen mode Exit fullscreen mode

For computation, improper fractions are easier to work with. Convert to mixed numbers only for final display.

Real-world fraction scenarios

Woodworking and construction. Imperial measurements are fraction-based. Adding 3 5/8 inches to 2 3/16 inches requires finding a common denominator (16ths), converting, adding, and simplifying. Messing this up means your shelf does not fit.

Recipe scaling. Tripling a recipe that calls for 2/3 cup of flour: 2/3 * 3 = 6/3 = 2 cups. Halving a recipe that calls for 3/4 cup: 3/4 * 1/2 = 3/8 cup. Simple in principle, easy to mess up when you are converting between cup, tablespoon, and teaspoon measurements simultaneously.

Probability. The probability of rolling a 7 with two dice is 6/36 = 1/6. Keeping probabilities as fractions preserves exactness and makes combined probability calculations (multiplication of independent events) cleaner.

Music theory. Time signatures are fractions. A 3/4 time signature means three quarter-note beats per measure. Note durations are fractions of a whole note: half, quarter, eighth, sixteenth.

I built a fraction calculator at zovo.one/free-tools/fraction-calculator that handles all four operations with automatic simplification, mixed number support, and step-by-step solution display. Useful when you need a quick exact answer without doing the LCD dance in your head.


I'm Michael Lip. I build free developer tools at zovo.one. 500+ tools, all private, all free.

Top comments (0)