What is the most efficient method when adding fractions and subsequently reducing by dividing by the GCD?
Method 1:
a/b + c/d = (a*d + b*c) / b*d
Method 2:
x = lcm(b, d)
[a * (x / b) + c * (x / d)] / x
What is the most efficient method when adding fractions and subsequently reducing by dividing by the GCD?
Method 1:
a/b + c/d = (a*d + b*c) / b*d
Method 2:
x = lcm(b, d)
[a * (x / b) + c * (x / d)] / x
Method 3:
which minimizes the chance of overflow by reducing the magnitude of the values in the calculation.
Overflow checks need still be done.
Even with infinite precision values, the above may reduce allocation costs (bigger numbers use more memory).
Oh, and profile,