Your code
int cnt=0; while (number& 1 ==0) { cnt++; number>>=1; }
has an error. For example, if the number is 0, then the loop will be infinite.
I would rewrite it as follows
int cnt = 0; if ( number ) while ( !( number & ( 1 << cnt++ ) ) );
In this case, if the number is not 0, the position (cnt) of the set bit will be counted from 1. Otherwise, the position will be 0.
source share