The & is a bitwise AND operator. You need to know a bit of binary numbers to know how that function works.
Negative numbers are represented using the two's complement notation, where the leftmost bit is used to indicate whether the number is positive (if 0) or negative (if 1).
A number is a power of 2 if it is represented by a sequence of binary digits, whose value is 0 for all but one. For instance, 2^6 = 64 is represented by 0100 0000
The corresponding negative number is calculated by applying a bitwise NOT operator (i.e. changing all 0 to 1 and all 1 to 0), then adding 1 to the result - in our example:
0100 0000 becomes 1011 1111 + 1 = 1100 0000
If you line up the 2 binary numbers:
0100 0000
1100 0000
and apply the bitwise AND, the resulting number is the original number 64:
0100 0000
That explains why number & -number == number
is used to determine whether a number is a power of 2.
To prove that, let's try with a couple other numbers not power of 2:
0100 0001 (65)
1011 1111 (-65)
---------
0000 0001 (1)
0000 0011 (3)
1111 1101 (-3)
---------
0000 0001 (1)