bool result = false; result = CheckPowerOfTwo(8); Console.WriteLine(result.ToString()); static bool CheckPowerOfTwo(ulong number) { return (number != 0) && ((number & (number - 1)) == 0); }
7 如何检查一个数字是不是2的乘方,布布扣,bubuko.com
原文:http://blog.csdn.net/u011685627/article/details/33355857