Returns whether x is a power of two: 1, 2, 4, 8, ...
x
bool isPowerOf2(int x) => (x > 0) && ((x & (x - 1)) == 0);