List of utility methods to do Number Round
long | round(final long timeMs, final int precision) round final long scale = (long) Math.pow(10, precision); return ((timeMs) / scale) * scale; |
int | round(int a, int cutOfDigits) Math#round(double) -like operation for integers, e.g.:
if (cutOfDigits <= 0) return a; int fac = 1; while (--cutOfDigits >= 0) fac *= 10; int ret = (a / fac) * fac; if (a - ret > fac / 2) ret += fac; ... |
int | round(int f) round return f < 0 ? -((-f + 32768) & ~0xFFFF) : (f + 32768) & ~0xFFFF;
|
int | round(int n) round if (n > 0) { if ((n & 0x8000) != 0) { return (((n + 0x10000) >> 16) << 16); } else { return (((n) >> 16) << 16); } else { int k; ... |
int | round(int start, int boundary) round return (start + boundary) & ~boundary;
|
double | round(int t, int n, int decimals) round double exp = Math.pow(10, decimals); return Math.round(exp * t / n) / exp; |
int | round(int top, int div2, int divisor) Specialized rounding for use with integer wavelet transform. if (top > 0) return (top + div2) / divisor; else return (top - div2) / divisor; |
int | round(int x, int quantum) Returns nearest integer to x , divisible by quantum .
int ceil = ceil(x, quantum); int floor = floor(x, quantum); return (ceil - x < x - floor) ? ceil : floor; |
int | round(Integer a) Round. return Math.round(a.floatValue());
|
Number | round(Number number, Number unit) round double n = number.doubleValue(); double u = unit.doubleValue(); double r = Math.IEEEremainder(n, u); if (r < n / 2) { n -= r; } else { n = n + u - r; return new Double(n); |