Number of digits before the decimal point in the division of two numbers | Function to return the number of digits before the decimal in a / b ; Return the required count of digits ; Driver code
function countDigits ( a , b ) { return Math . floor ( ( Math . log ( Math . abs ( a ) ) / Math . log ( 10 ) ) - ( Math . log ( Math . abs ( b ) ) / Math . log ( 10 ) ) ) + 1 ; } var a = 100 ; var b = 10 ; document . write ( countDigits ( a , b ) ) ;