For an integer numberthat has digits n, this value is between 10^(n - 1)(included) and 10^n, therefore, log10(number)is between n - 1(included) and n. Then the function floorreduces the fractional part, leaves the result as n - 1. Finally, adding to it 1gives the number of digits.