title: How to round a number up to nearest x incremental value
body: <p>Im having issues with a block of code that involves rounding floats to the nearest upper x. What i'm trying to do is take whatever number i have and round it up to the next highest x. My code seems to work 80% of the time, but have recently found some cases where it is not returning a number that i would expect. For example, if i wanted it rounded to the next highest 500, the code below shows what i would have.</p>
  
  <p><code>CGFloat number = 3780;
  roundedNumber = 500 *ceilf(number/500 +.5);</code></p>
  
  <p>Here i would expect the answer to return 4000. Instead, it returns 4,500.</p>
  
  <p>Is there something about the math above that i am missing/not understanding? why is it only for some case this seems to "over round" my numbers? is there a simpler way to get what i'm after than this?</p>