Android examples for java.lang:Integer
Calculate next Power Of 2 via bit operation
public class Main { public static int nextPowerOf2(int n) { n -= 1;//w w w .j a va 2 s. co m n |= n >>> 16; n |= n >>> 8; n |= n >>> 4; n |= n >>> 2; n |= n >>> 1; return n + 1; } }