Back to articles
Mixed Fractions Are Just Bad UX for Improper Fractions

Mixed Fractions Are Just Bad UX for Improper Fractions

via Dev.to TutorialMichael Lip

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 The general formula: function mixedToImproper ( whole , numerator , denominator ) { return { numerator : whole * denominator + numerator , denominator : denominator }; } 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 Step 2: Find common denominator (LCM of 4 and 3 = 12) 11/4 = 33/12 5/3 = 20/12 Step 3: Add 33/12 + 20/12 = 53/12 Step 4: Convert back to mixed 53/12 = 4 5/12 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 co

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
2 views

Related Articles