Results 1 to 3 of 3
Thread: Rounding
- 11-17-2009, 03:01 AM #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
- 11-17-2009, 03:10 AM #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
- 11-17-2009, 08:16 AM #3
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
rounding double to two decimal places
By javaMike in forum Advanced JavaReplies: 15Last Post: 03-10-2010, 12:04 AM -
[SOLVED] Rounding off numbers
By Manfizy in forum New To JavaReplies: 4Last Post: 02-07-2009, 12:44 AM -
rounding a double in a number of significant numbers
By rikribbers in forum Advanced JavaReplies: 2Last Post: 10-27-2008, 03:35 PM -
Need help rounding. =/
By yo1mcool in forum New To JavaReplies: 1Last Post: 10-07-2008, 05:02 AM -
Help with java Rounding
By silvia in forum New To JavaReplies: 1Last Post: 07-20-2007, 07:25 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks