# How does the logarithm returns the number of digits of a number? [duplicate]

A number written in base b is a polynomial $\sum {(a_i*b^i)}=a_n...a_3a_2a_1a_0$

The logarithm in base b of the number gives the number of digits (up to with a constant=1 difference), and I want to understand how it does that. Note that as the base gets smaller, the result gets more precise.

I want to understand how the logarithm processes each element of the polynomial to get the result.. The entire process, and not a rough approximation.

I made a program that composes the text of a Taylor series for log(1+x) with a polynomial with 10 terms, but the result is a text file with hundreds of Mb, so it is unreadable.

I understand that the largest term is approximately $n+log_b(a_n)$, but I want a more precise understanding. A rough explanation based on bounds is what I already know. I have no interest on that, unless it is part of the entire explanation.

## marked as duplicate by Simply Beautiful Art, Arthur, Rohan, TastyRomeo, Adam HughesFeb 15 '17 at 15:23

• @Simply Beautiful Art No. Your link only explains approximately what I said when I wrote $n+log_b(a_n)$. As I said, I want the complete process, not just an approximation. – xihocipi Feb 15 '17 at 12:28
• It gives exactly how many digits a number has in a given base. What approximation do you mean? – Simply Beautiful Art Feb 15 '17 at 12:34
• You didn't read the selected answer. – xihocipi Feb 15 '17 at 12:36
• I see nothing wrong with the below answer. The digits themselves play absolutely no role in how many digits there are. Unless you more clearly state what's wrong with the below, I cannot help you. – Simply Beautiful Art Feb 15 '17 at 12:38
• Of course the digits play a role in how many digits the number have. The encoding size in binary of 64 is larger than the encoding size of 16. I'm asking what the logarithm does to each element of the polynomial. – xihocipi Feb 15 '17 at 12:42

Let's consider the base $b=10$. Other bases are handled the same way.

If $N$ is a positive integer which has $p$ digits in base $10$, we have :

$$10^{p-1}\le N<10^p$$ Hence :

$$p-1\le\log_{10}(N)<p$$

This last condition is equivalent to :

$$p=\lfloor1+\log_{10}(N)\rfloor$$

• That is just what I wrote expressed in another way. It does not explains what the logarithm does with the polynomial, piece by piece. One difficulty is that there is not a closed form of $log(a+b)=f(log(a),log(b))$ – xihocipi Feb 15 '17 at 12:30
• @xihocipi I only see some inequalities, the definition of logarithms, and silent use of monotonicity. There should be no more required to answer this question. – Simply Beautiful Art Feb 15 '17 at 12:40
• @xihocipi it doesn't matter what $\log$ does with a sum. What matters is your number can be written as $N=\alpha\times 10^{p-1}$ for $1\leq \alpha<10$ and $\log(N)=\log(\alpha\times 10^{p-1})=\log(\alpha)+\log(10^{p-1})=p-1+\log(\alpha)$ --- and $\log(\alpha)<1$; i.e what matters is what $\log$ does to a product. – JP McCarthy Feb 15 '17 at 13:11
• You are just trowing away $log(\alpha)$ under the carpet, and there is the meat of the problem. – xihocipi Feb 15 '17 at 13:21
• I said that I composed a polynomial with a taylor series, to examine what is the result, and you discard all that hard work as it were non relevant. – xihocipi Feb 15 '17 at 13:23