标签:
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 }
Power of Two
原文地址:http://www.cnblogs.com/boluo007/p/5483798.html