So I this isn't specific to coding, but I want to know of a clever way to round a number in a specific manner.
So say I have the following number:
I want to take that number and round up to the next hundred.
For example, the number should be:
Regardless of what that number should actually round to, I want to always take it and round it up to the next hundred....
A few more examples:
983,930.00 --> 984,000.00
324,802.00 --> 324,900.00
500.00 --> 500.00 (this is the only exception)
Can anyone think of a clever way to do this?
Thanks in advance
I was thinking:
Take your number:
59,343.00 / 100
= 593.43 - use Math.rounding, round UP
= 594.00 * 100
as long as 59,343 mod 100 does not = 0, i should round up
You can keep it integral.
If (number % 100) > 0 then add 100 to number - (number % 100).