List of utility methods to do Number Round
double | roundUpNumberByUsingMultipleValue(double number, double multiple) Round up number by using multiple value. double result = multiple; if (number % multiple == 0) { result = number; } else if (number % multiple != 0) { if (number >= 0) { int division = (int) ((number / multiple) + 1); result = division * multiple; } else { ... |
int | roundUpPOT(int value) round Up POT return 1 << (32 - Integer.numberOfLeadingZeros(value - 1));
|
int | roundUpPow2(int x) Rounds an integer up to the next power of 2. if (x <= 0) { return 1; } else if (x > 0x40000000) { throw new IllegalArgumentException( "Rounding " + x + " to the next highest power of two would exceed the int range"); } else { x--; x |= x >> 1; ... |
int | roundUpPower2(int i) round Up Power i--;
i |= i >> 1;
i |= i >> 2;
i |= i >> 4;
i |= i >> 8;
return (i | (i >> 16)) + 1;
|
int | roundUpPower2(int v) round Up Power switch (Integer.bitCount(v)) { case 0: return (1); case 1: return (v); default: return (Integer.highestOneBit(v) << 1); |
double | roundUpTo(double in, double del) round in up to the next even multiple of del int n = (int) (in / del); double ret = n * del; if (ret == in) return (ret); return (ret + del); |
int | roundUpTo(int a, int quanta) round Up To return (a + (quanta - 1)) & -quanta;
|
long | roundUpTo(long i, long multiple) round Up To return (i + multiple - 1L) & ~(multiple - 1L);
|
int | roundUpTo100(int n) round Up To int rem = n % 100; if (rem == 0) return n; return n + (100 - rem); |
long | roundUpTo8(final long number) round Up To return ((number + 7) / 8) * 8;
|