Multiplication and division question
If some known division problems can be converted into a number that can be used to multiply to get the same answer like (number / 2) is the same as (number * 0.5).
Is there a math calucation to determin what number should be multiplied from a division number ?
Number * (1/X) where X is the divisor in your original code (number/X).
Just precalc the 1/X part. (1/2 = 0.5 for instance)
Just precalc the 1/X part. (1/2 = 0.5 for instance)
A * (1 / D)
Where you would normally go 1/d
You can precalculate 1/d, or let your compiler do that for you. (assuming an optimising compiler).
The reson why this works?
Fractions,
A = A/1 (fractional)
Fractional division = reciprical & fractional multiplication
You calculate the recipcial by doing 1/d, you then do the fractional multiplication by doing the *. (this works because they all have the same demoninator, 1)
From,
Nice coder
Where you would normally go 1/d
You can precalculate 1/d, or let your compiler do that for you. (assuming an optimising compiler).
The reson why this works?
Fractions,
A = A/1 (fractional)
Fractional division = reciprical & fractional multiplication
You calculate the recipcial by doing 1/d, you then do the fractional multiplication by doing the *. (this works because they all have the same demoninator, 1)
From,
Nice coder
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement