Jump to content
  • Advertisement
Sign in to follow this  
yurian

Finding multiples of a set number =)

This topic is 4112 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

Just wondering, is there a super efficient way to find multiples of a number? If I have incorectly asked my question, I mean, suppose one day, people's heads will suddenly explode for no reason. There is a line of 36 people, and 360 miles of land. And some guy controling physics of the world is programming the "earth's computer" so that every 10 miles the line of people walk, one person will go boom. How would he do this? Ooh, sorry =) : Also I dont understand the allegro doc or chm, so I cant look for this answer: Does set_color_depth(16); mean I can only use 16 bit bitmaps? My games look badly discolored

Share this post


Link to post
Share on other sites
Advertisement
Choose a number n (for instance, 10).

Multiply this number by an integer, m (for instance, 2).

The result (here, 20) is a multiple of n.

Share this post


Link to post
Share on other sites
Choose a number N (say 100)
Choose to find if it is a multiple of M (10 for instance)
The result is remainder 100/10 == 0 determined easily in C++ with modulus
100 % 10 == 0
or with floating point numbers
fmod ( 100, 10 ) == 0

Any non-multiple will result in a non-zero remainder.

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!