Check if a Number Is a Power of 2 the Easier Way Aug 8th, 2005 This one-liner does the trick. 1 ((x > 1) && !(x & (x - 1))) Clue: “every power of 2 has only one bit set in the binary representation”