The expression a&=a-1;
clears the least significant bit (rightmost 1) of a
. In this case, the code counts the number of bits in a
(-1).
Beginning with
a = -1 ; // 11111111 11111111 11111111 11111111 32bits signed integer
Code output 32
in 32-bit integer configuration.
source
share