My function converts an improper fraction to a mixed number (it does not AND should not simplify the fraction).
// Improper fraction to mixed number
// n = numerator
// d = denominator
// i = number
function improperFractionToMixedNumber(n, d) {
i = (n / d) >> 0;
n -= i * d;
return [i, n, d];
}
// Convert 14/4 to mixed number
improperFractionToMixedNumber(14, 4); // 3, 2, 4
Can this be improved or simplified?
I don't care for this part:
i = (n / d) >> 0;
But it's the only way I could figure out how to see how many times a number equally divides into another number.