What is the relationship between base and number of digits?

For instance, the number $1000$ takes $4$ digits in base $10$, $10$ digits in base $2$, $3$ digits in base $20$, and $2$ digits in base $1000$.

What is the mathematical relationship between number of digits and base?


Solution 1:

Let $n$ be a positive integer. The base $b$ representation of $n$ has $d$ digits if $b^{d-1}\le n<b^d$, which is the case if $d-1\le\log_b n<d$, or $\lfloor\log_bn\rfloor=d-1$. The number of digits in the base $b$ representation of $n$ is therefore

$$\lfloor\log_bn\rfloor+1=\left\lfloor\frac{\ln n}{\ln b}\right\rfloor+1\;.$$

When $n$ is large compared with $b$, it’s roughly inversely proportional to $\ln b$.

Solution 2:

$N$ in base $10$ has $\lfloor\log_mN\rfloor+1$ digits in base $m$.

Solution 3:

If $$10^n \le x < 10^{n+1},$$ then $x$ has $n+1$ digits in base $10$ and $$ 4^{n\log_4 10} \le x < 4^{(n+1)\log_4 10} $$ Find out which integers $n\log_{10}4$ is between and which integers $(n+1)\log_{10}4$ is between. That will tell you something about the number of digits that $x$ has in base $4$.

Multiplying the number of base-$10$ digits by $\log_4 10$ gives you the approximate number of base-$4$ digits.