Number of digits before the decimal point in the division of two numbers | Java implementation of the approach ; Function to return the number of digits before the decimal in a / b ; Return the required count of digits ; Driver code
class GFG { public static int countDigits ( int a , int b ) { double digits = Math . log10 ( Math . abs ( a ) ) - Math . log10 ( Math . abs ( b ) ) + 1 ; return ( int ) Math . floor ( digits ) ; } public static void main ( String [ ] args ) { int a = 100 ; int b = 10 ; System . out . print ( countDigits ( a , b ) ) ; } }