List of utility methods to do Number Round
double | RoundHalfUp(double d) Round Half Up return .5 * Math.ceil(d / .5);
|
double | roundIfClose(double val) Local function to round "sufficiently close" Number values to whole numbers, to prevent unnecessary aliasing in drawing shapes. double nVal = Math.round(val); if (Math.abs(val - nVal) < 0.001) { return nVal; } else { return val; |
String | Rounding(double d, int i) Rounding long a = (long) d; long b = (long) ((d - a) * Math.pow(10, i)); return a + "." + b; |
double | rounding(double val) rounding long value = (long) val; long decVal = 1; for (long x = value; x >= 10; x /= 10) { decVal *= 10; if (value > decVal * 5) { return decVal * 10; } else if (value > decVal * 2) { ... |
int | roundingRightShift(int x, int count) Right-shift x by count bits, and round the result using half-even rounding. int remainder; if (count > 32) { return 0; } else if (count == 32) { remainder = x; x = 0; } else { remainder = x << (32 - count); ... |
int | roundIntegerToNearestUpperTenth(int a) round Integer To Nearest Upper Tenth int remainder = a % 10; while (remainder != 0) { a += 1; remainder = a % 10; return a; |
int | roundInventorySize(final int size) round Inventory Size if (size > 9 && size <= 18) { return 18; } else if (size > 18 && size <= 27) { return 27; } else if (size > 27 && size <= 36) { return 36; } else if (size > 36 && size <= 45) { return 45; ... |
String | roundJs(double v, int n) round Js return String.valueOf(v);
|
long | roundLong(double a) Returns a double rounded to the nearest integer. return (long) Math.floor(a + 0.5); |
int | roundM(int n, int m) round M return (int) (Math.floor((n + m - 1) / m) * m); |