#include "stdio.h" //判断一个数是2的整数次幂算法 输出为0则表示是 输出其他表示非2的整数次幂 int two(int n) { return n & (n-1); } int main() { printf("%d\n",two(1023)); return 0; }
判断一个整数是否为2的整数次幂
原文:http://blog.csdn.net/itbuluoge/article/details/19195745