The Five Math Operations That Cover 90% of Programming Problems
After years of building tools and reviewing code, I have found that the vast majority of mathematical operations in production software come down to five categories. You don't need a math degree. Y...

Source: DEV Community
After years of building tools and reviewing code, I have found that the vast majority of mathematical operations in production software come down to five categories. You don't need a math degree. You need fluency in these five areas. 1. Percentage calculations Percentages appear everywhere: discounts, tax, tips, progress bars, analytics dashboards, A/B test results. // What is X% of Y? const percentOf = (percent, total) => (percent / 100) * total; // What percentage is X of Y? const whatPercent = (part, total) => (part / total) * 100; // Percentage change from A to B const percentChange = (oldVal, newVal) => ((newVal - oldVal) / oldVal) * 100; The percentage change formula is the one developers get wrong most often. The denominator is the old value, not the new one. Going from 50 to 75 is a 50% increase. Going from 75 to 50 is a 33.3% decrease. The asymmetry catches people. 2. Linear interpolation Mapping a value from one range to another. Used in animations, data visualizatio