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