int a = 12;
for eg: binary of 12 is 1100 so answer should be 3 as 3rd bit from right is set.
I want the position of the last most set bit o
Accourding to dbush's solution, Try this:
int rightMostSet(int a){ if (!a) return -1; //means there isn't any 1-bit int i=0; while(a&1==0){ i++; a>>1; } return i; }