47 return ( 1 << n ) - 1;
48 }
else if ( 32 == n ) {
51 throw new IndexOutOfBoundsException(
"n <= 32 expected, is "+n);
80 n = n - ((n >>> 1) & 0x55555555);
81 n = (n & 0x33333333) + ((n >>> 2) & 0x33333333);
82 n = (n + (n >>> 4)) & 0x0f0f0f0f;
95 return 0<n && 0 == (n & (n - 1));
114 return (n < 0) ? 1 : n + 1;
static final int roundToPowerOf2(final int n)
If the given n is not isPowerOf2(int) return nextPowerOf2(int), otherwise return n unchanged.
static final boolean isPowerOf2(final int n)
Returns true if the given integer is a power of 2.
static final int bitCount(int n)
Returns the number of set bits within given 32bit integer in O(1) using a HAKEM 169 Bit Count inspire...
static final int nextPowerOf2(int n)
Returns the next higher power of 2 of 32-bit of given n @endiliteral.
static int getBitMask(final int n)
Returns the 32 bit mask of n-bits, i.e.
static final int MAX_POWER_OF_2
Maximum 32bit integer value being of isPowerOf2(int).
static final int UNSIGNED_INT_MAX_VALUE
Maximum 32 bit Unsigned Integer Value: 0xffffffff == {@value}.