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
< ? php function msbPos ( $ n ) { $ msb_p = -1 ; while ( $ n > 0 ) { $ n = $ n >> 1 ; $ msb_p ++ ; } return $ msb_p ; }