text: Find most significant bit of a number X in base Y | Java Program to find the first digit of X in base Y ; Function to find the first digit of X in base Y ; calculating number of digits of x in base y ; finding first digit of x in base y ; Driver code
code: import java . util . * ; class GFG { static void first_digit ( int x , int y ) { int length = ( int ) ( Math . log ( x ) / Math . log ( y ) + 1 ) ; int first_digit = ( int ) ( x / Math . pow ( y , length - 1 ) ) ; System . out . println ( first_digit ) ; } public static void main ( String args [ ] ) { int X = 55 , Y = 3 ; first_digit ( X , Y ) ; } }