Jump to content
  • Advertisement
Sign in to follow this  
mrhodes

Simple math problem

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

Hey everyone... I have a simple problem. best way to ask this is with an example :) int i = 25 / 10; I need this to equal 3. But I only ever get 2. I am writing code that breaks up data into smaller portions and in the about example I would need to know that I need 3 portions to store 25 whereas 2 portions would only store 20... know what I mean? Thanks for the help Michael

Share this post


Link to post
Share on other sites
Advertisement
The easiest way is to add the divisor - 1. so (25 + (10-1) ) / 10 = 3.

Then anything from 21-30 is 3, 31-40 is 4, etc.

Share this post


Link to post
Share on other sites
Ironpoint: Thanks for the quick reply.... that works and is exactly what I'm looking for :)


Mike

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!