# Thread: Rounding

1. Member
Join Date
Jan 2009
Posts
92
Rep Power
0

## Rounding

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:

59,323.00

I want to take that number and round up to the next hundred.

For example, the number should be:

59,400.00

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

2. Member
Join Date
Jan 2009
Posts
92
Rep Power
0
I was thinking:

Take your number:

59,343.00 / 100

= 593.43 - use Math.rounding, round UP

= 594.00 * 100

= 59,400.00

as long as 59,343 mod 100 does not = 0, i should round up

3. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
11
You can keep it integral.
If (number % 100) > 0 then add 100 to number - (number % 100).

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•