DEV Community

Michael Lip
Michael Lip

Posted on • Originally published at zovo.one

Mixed Fractions Are Just Bad UX for Improper Fractions

Mixed fractions exist because humans find them easier to visualize. Computers find them harder to compute. Every mixed fraction calculation starts by converting to an improper fraction, doing the math, and converting back.

Converting mixed to improper

A mixed fraction like 3 2/5 (three and two-fifths) converts to an improper fraction:

3 2/5 = (3 * 5 + 2) / 5 = 17/5
Enter fullscreen mode Exit fullscreen mode

The general formula:

function mixedToImproper(whole, numerator, denominator) {
  return {
    numerator: whole * denominator + numerator,
    denominator: denominator
  };
}
Enter fullscreen mode Exit fullscreen mode

Arithmetic with mixed fractions

To add 2 3/4 + 1 2/3:

Step 1: Convert both to improper fractions

2 3/4 = 11/4
1 2/3 = 5/3
Enter fullscreen mode Exit fullscreen mode

Step 2: Find common denominator (LCM of 4 and 3 = 12)

11/4 = 33/12
5/3 = 20/12
Enter fullscreen mode Exit fullscreen mode

Step 3: Add

33/12 + 20/12 = 53/12
Enter fullscreen mode Exit fullscreen mode

Step 4: Convert back to mixed

53/12 = 4 5/12
Enter fullscreen mode Exit fullscreen mode
function gcd(a, b) {
  return b === 0 ? a : gcd(b, a % b);
}

function lcm(a, b) {
  return (a * b) / gcd(a, b);
}

function addFractions(n1, d1, n2, d2) {
  const commonDenom = lcm(d1, d2);
  const newN1 = n1 * (commonDenom / d1);
  const newN2 = n2 * (commonDenom / d2);
  const sumN = newN1 + newN2;
  const divisor = gcd(Math.abs(sumN), commonDenom);
  return { numerator: sumN / divisor, denominator: commonDenom / divisor };
}

function improperToMixed(numerator, denominator) {
  const whole = Math.floor(numerator / denominator);
  const remainder = numerator % denominator;
  return { whole, numerator: remainder, denominator };
}
Enter fullscreen mode Exit fullscreen mode

Why this matters in programming

Fractions appear in unexpected places: time calculations (3 hours 45 minutes = 3 3/4 hours), measurements (2 1/2 cups), music (time signatures), and any domain that needs exact rational arithmetic rather than floating-point approximation.

1/3 cannot be represented exactly in floating point. As a fraction, it is exactly 1/3. For applications requiring exact arithmetic, fraction libraries are essential.

For computing mixed fraction arithmetic with step-by-step solutions, I built a calculator at zovo.one/free-tools/mixed-fraction-calculator. It handles addition, subtraction, multiplication, division, and simplification, showing each conversion step.


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

Top comments (0)