Count total bits in a number | Function to get no of bits in binary representation of positive integer ; Driver Code
function countBits ( n ) { var count = 0 ; while ( n != 0 ) { count ++ ; n >>= 1 ; } return count ; } var i = 65 ; document . write ( countBits ( i ) ) ;