He's basically using bitwise operators to check for an odd number (m & 1) and to floor-divide by 2 (m >>= 1).
This is the equivalent of the following (without bitwise operators):
def myPow(self, x, n):
m = abs(n)
ans = 1.0
if m % 2:
ans *= x
x *= x
m //= 2
return ans if n >= 0 else 1 / ans
Shifting all the bits 1 to the right (m >>= 1) has the effect of cutting an integer in half and dropping the remainder. The bitwise and (m & 1) basically compares the last bit in m with the single bit in 1, and if they're both 1 then it evaluates to 1 (otherwise it evaluates to 0). So odd m will evaluate to 1 (or True), and even m will evaluate to 0 (or False).
@jaewoo If the n=-2147483648, would it not be your result =1? I just do not see how your code avoids the error symao's code makes. I mean your code will not get into infinite loop, but it does not give right answer for cases like pow(2, -2147483648) for eg.