1. Extract the last set bit
x & (-x)
eg. x: 00110010
-x: 11001101 + 1 = 11001110
x & (-x) = 00000010
2. Remove the last set bit
x – x & (-x)
1. Extract the last set bit
x & (-x)
eg. x: 00110010
-x: 11001101 + 1 = 11001110
x & (-x) = 00000010
2. Remove the last set bit
x – x & (-x)