Power of Two

Given an integer, write a function to determine if it is a power of two.

2的幂数二进制只有一个1

1 bool isPowerOfTwo(int n) {
2     if(n <= 0)
3         return 0;
4     return (n & (n-1)) == 0;
5 }
原文地址:https://www.cnblogs.com/boluo007/p/5483798.html