Will Do
Thoughts on technology, the world, and life.

Is An Integer A Power Of Two?

Java:

boolean power2(int x) {
    return x != 0 && (x & (x - 1)) == 0;
}

A power of two must be greater than zero.

π