A function to return ceiling of log x in base 2. For example , it returns 3 for 8 and 4 for 9.
function ceilLog2 ( $ x ) { $ count = 0 ; $ x -- ; while ( $ x > 0 ) { $ x = $ x >> 1 ; $ count ++ ; } return $ count ; }