School-Coding-Cpp/sfusi/verifica_se_x_è_una_potenza...

17 lines
238 B
C++

#include <iostream>
using namespace std;
int main(void) {
int x = 1024;
bool isPowerOfTwo = x && !(x & (x - 1));
if (isPowerOfTwo) {
cout << "true" << endl;
} else {
cout << "false" << endl;
}
return 0;
}