public static int roundToPowerOfTwo(final int value) {
        if (value > MAX_POW2) {
            throw new IllegalArgumentException("There is no larger power of 2 int for value:"+value+" since it exceeds 2^31.");
        }
        final int nextPow2 = 1 << (32 - Integer.numberOfLeadingZeros(value - 1));
        return nextPow2;
    }
public static int roundToPowerOfTwo ( final int value ) { if ( value > MAX_POW2 ) { throw new IllegalArgumentException ( "There is no larger power of 2 int for value:" + value + " since it exceeds 2^31." ) ; } final int nextPow2 = 1 << ( 32 - Integer . numberOfLeadingZeros ( value - 1 ) ) ; return nextPow2 ; }
@param value from which next positive power of two will be found.
@return the next positive power of 2, this value if it is a power of 2. Negative values are mapped to 1.
@throws IllegalArgumentException is value is more than MAX_POW2