List of utility methods to do Ceil
int | ceilPositive(float x) Returns the smallest integer greater than or equal to the specified float. return (int) (x + CEIL); |
int | ceilPoT(int arg) Computes closest power of two that is not less than argument. if (arg < 1) throw new IllegalArgumentException("Argument of ceilPoT must be two or greater."); if (arg > 0x40000000) throw new IllegalArgumentException("Argument of ceilPoT greater than 2^31."); --arg; arg |= arg >> 1; arg |= arg >> 2; arg |= arg >> 4; ... |
int | ceilPow2(int v) Gets nearest power of 2 larger or equal than v. v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
return ++v;
|
long | ceilPowerOf2(final long x) Get the smallest long which is a power of 2 and > x. if (x >= (1L << 62) || x < 0) { throw new IllegalArgumentException("Number out of range:" + x); long i = 1L; while (i <= x) { i = i << 1; return i; ... |
int | ceilPowerOf2(int x) Rounds up the value to the nearest higher power^2 value. int pow2 = 1; while (pow2 < x) { pow2 <<= 1; return pow2; |
int | ceilPowerOf2Bits(final long x) Get the smallest power of 2 > x. if (x >= (1L << 62) || x < 0) { throw new IllegalArgumentException("Number out of range:" + x); long i = 1L; int n = 0; while (i <= x) { assert i > 0; assert n >= 0; ... |
long | ceilPrime(long p) ceil Prime if (p == 1) p++; while (!isPrime(p)) p++; return p; |
long | ceilSec(long milli) ceil Sec return ((milli + 999L) / 1000L) * 1000L;
|
int | ceilToBase(int number, int base) ceil To Base if (base == 0) { return 0; if (number == 0) { return base; if (number < 0) { base *= -1; ... |
int | ceilToPowerOfTwo(float value) Ceils the given value to the closest number that's is a power of two. int size = 2; while (size < value) { size *= 2; return size; |