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