i += i & -i
12345678
10 & 3 = 2, because: dec | hex | bin _______________ 10 0xA 1010 3 0x3 0011 &&&& 2 0x2 0010
12345678910
i -> i&-i _________ 1 -> 1 2 -> 2 3 -> 1 4 -> 4 5 -> 1 6 -> 2 7 -> 1 8 -> 8