I\'m writing an application which requires rounding labels to the nearest \'nice\' number. I\'ll put some code below to demonstrate this, but my issue is that I was using a ser
I came up with this quite crude solution, which returns the correct values for all of the cases I tested just now:
public static double foo(long value) {
for (double i = 0.2; true; i *= 5) {
if (i >= value) {
return i / 5;
}
}
}
Although I must admit that a mathematical solution as posted by Groo would be more beautiful. ;)