i & -i

i & -i store the right most 1 of i only

12 & -12 = 4
0b1100 & 0b0100 = 0b0100 = 4
def lowbit(self, x):
        return x & -x

你可能感兴趣的:(i & -i)