public static int CeilPowerOf2(int x) { int pow2 = 1; while (pow2 < x) { pow2 <<= 1; } return pow2; }