# Are there more convenient ways of getting the number of digits of a positive integer?

I want to define $n$th power of $10$ for a positive integer. Say for $43$ it would be $2$, for $5$ it would be $1$, for $9999$ it would be $4$. As for $1$, $10$, $100$, ... I am still shifting between two options. $10$ would result either $1$ or $2$. But for simplicity I select it to be $2$.

In other words I want to get the number of digits of a positive integer with proper mathematical notation.

So far I have managed to do it with log and round:

$$\operatorname{floor}(\log_{10}(43))+1 = 2$$

I'm just not sure if this is good approach. As a bonus it would be nice to have a solution working with any base, not just 10.

I'm not sure what you find inconvenient; given any natural number $b\geq 2$, the number of base-$b$ digits of a given natural number $n$ is exactly equal to $$\lfloor\strut\log_b(n)\rfloor+1$$ That's because, if $$n=(d_kd_{k-1}\ldots d_1d_0)_b=d_kb^k+d_{k-1}b^{k-1}+\cdots+d_1b+d_0$$ where each digit $d_i$ satisfies $0\leq d_i\leq b-1$ and $d_k\neq 0$, we have $$b^k\leq n<b^{k+1}$$ and because the logarithm is convex, this implies $$k\leq \log_b(n)<k+1$$ so that $\lfloor\log_b(n)\rfloor = k$, and therefore $\lfloor\log_b(n)\rfloor+1=k+1$, which is indeed the number of digits in the base $b$ expansion of $n$.