Hello,
I'm trying to find the least significant set bit (i.e. the first '1' bit in an int) through just bit twiddling, but I can't get it without resorting to a loop. My original idea was to reverse the bits in an int and find the most significant bit then subtract it from 31 to get the position of the LSB. Is there a way to get the LSB of an int using just bit manipulations?
e.g., 0b0101 would return 0001,
0b0000 would return 0000,
0b1110 would return 0010.
Thanks