7 怎样检查一个数字是不是2的乘方
bool result = false; result = CheckPowerOfTwo(8); Console.WriteLine(result.ToString()); static bool CheckPowerOfTwo(ulong number) { return (number != 0) && ((number & (number - 1)) == 0); }
bool result = false; result = CheckPowerOfTwo(8); Console.WriteLine(result.ToString()); static bool CheckPowerOfTwo(ulong number) { return (number != 0) && ((number & (number - 1)) == 0); }