fork(3) download
  1. #include <iostream>
  2.  
  3. bool isPowerOf2(int number) { return !(number & (number - 1)); }
  4.  
  5. int main() {
  6. std::cout << isPowerOf2(1024) << std::endl;
  7. std::cout << isPowerOf2(1023) << std::endl;
  8. std::cout << isPowerOf2(0) << std::endl;
  9. return 0;
  10. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
1
0
1