There is any general formula to get the number of decimal digits in a decimal number?
For example in 8.888, there are 3 decimal digits.
Thanks for any reply!
There is any general formula to get the number of decimal digits in a decimal number?
For example in 8.888, there are 3 decimal digits.
Thanks for any reply!
Copyright © 2021 JogjaFile Inc.
No, there is at least no way given an arbitrary real number.
For positive integers this is easy, the answer involves logarithms and you probably know it already. The number of digits of $n$ is $$\lfloor \log_{10} n\rfloor +1$$
For rational numbers $\frac ab$ given as a fraction in lowest terms, there are infinitely many digits unless there is a $k$ such that $10^k\frac ab$ is an integer. In that case it is the smallest such $k$ plus the number of digits of the floor of the number.
For irrational numbers the number is obviously infinity. However there is provably no general method for determining if a number is rational. So you can do integers or fractions, but not general real numbers.