Jump to content
  • Advertisement
Sign in to follow this  
digital_phantom

Multiplication and division question

This topic is 5054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
Advertisement
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!