Java Utililty Methods Power of 2

List of utility methods to do Power of 2

Description

The list of methods to do Power of 2 are organized into topic(s).

Method

intnextPowerOfTwoExact(int n)
Finds the first power of two that is equal to or greater than n.
int highest = Integer.highestOneBit(n);
return (highest == Integer.lowestOneBit(n)) ? highest : highest << 1;
intnextPowerOfTwoValue(double value)
This method will return the next power of two for the given value, e.g.
int power = previousPowerOfTwo(value);
return 1 << power;
intnextPowerTwo(int initialNum)
next Power Two
int num = 1;
while (num < initialNum)
    num <<= 1;
return num;