bitwise operators - How to get position of right most set bit in C -
int = 12;
for eg: binary of 12 1100 answer should 3 3rd bit right set.
i want position of last set bit of a
. can tell me how can so.
note : want position only, here don't want set or reset bit. not duplicate of question on stackoverflow.
try this
int set_bit = n ^ (n&(n-1));
Comments
Post a Comment