Count total bits in a number | Function to get no of bits in binary representation of positive integer ; Driver program
class GFG { static int countBits ( int n ) { int count = 0 ; while ( n != 0 ) { count ++ ; n >>= 1 ; } return count ; } public static void main ( String [ ] arg ) { int i = 65 ; System . out . print ( countBits ( i ) ) ; } }