Find position of MSB in n . For example if n = 17 , then position of MSB is 4. If n = 7 , value of MSB is 3
int msbPos ( ll n ) { int msb_p = -1 ; while ( n ) { n = n >> 1 ; msb_p ++ ; } return msb_p ; }