List of utility methods to do Number Round
long | roundUp(long number, long mod) round Up return ((number + mod - 1L) / mod) * mod;
|
long | roundUp(long position, long sectionAlignment) round Up if (sectionAlignment < 0) throw new RuntimeException("Bad alignment: " + sectionAlignment); if (sectionAlignment == 0) sectionAlignment = 1; if (position % sectionAlignment != 0) return (position - (position % sectionAlignment)) + sectionAlignment; return position; |
long | roundUp(long size, int blockSize) round Up return ((size + blockSize - 1) / blockSize) * blockSize;
|
long | roundUp(long val, long delta) round Up boolean isNegative = val < 0; val = Math.abs(val); long old = val; val = val / delta * delta; if (val < old) val += delta; return !isNegative ? val : -val; |
long | roundup_2n(long val, int blocksize) Round up a value to the next multiple of a power of 2 int mask = blocksize - 1; return (val + mask) & ~mask; |
int | roundUpDivision(final int dividend, final int divider) round Up Division if (dividend == 0) { return 0; return (dividend + divider - 1) / divider; |
int | roundUpDown(int number, int by) round Up Down int result = number; if (by > 0) { result = number + (by - number % by); } else if (by < 0) { if (number % by == 0) { number--; result = number - number % by; } else { ... |
long | roundUpIfNecessary(long timeout, long convertedTimeout) round Up If Necessary if (timeout > 0 && convertedTimeout == 0) { return 1; return convertedTimeout; |
long | roundUpLong(long value, long interval) round Up Long return ((value + interval - 1) / interval * interval);
|
long | roundUpLong(long x, long blockSizePowerOf2) Round the value up to the next block size. return (x + blockSizePowerOf2 - 1) & (-blockSizePowerOf2);
|