In Java, how do I round to an arbitrary value? Specifically, I want to round to .0025 steps, that is:
0.032611 -> 0.0325
0.034143 -> 0.0350
0.035233 -> 0.0350
0.037777 -> 0.0375
...
Any ideas or libs?
In Java, how do I round to an arbitrary value? Specifically, I want to round to .0025 steps, that is:
0.032611 -> 0.0325
0.034143 -> 0.0350
0.035233 -> 0.0350
0.037777 -> 0.0375
...
Any ideas or libs?
You could do this:
double step = 0.0025;
double rounded = ((int)(unrounded / step + 0.5)) * step;