• Advertisement
Sign in to follow this  

Simple math problem

This topic is 4767 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
Sign in to follow this  

  • Advertisement