power of two c++ code example Example: power of two c++ bool IsPowerOfTwo(int x) { return x && ((x & (x - 1)) == 0); }