Bit Manipulation - Power of Four
Consider the following Python function to check if n is a power of four:
What is the subtle bug in this code?
def checkPowerOfFour(n):
return n > 0 and (n & (n - 1)) == 0 and (n & 0x55555555) != 0What is the subtle bug in this code?
