0

From here we have seen that there are exactly $\lfloor \log_{10} n \rfloor +1$ digits in a decimal number $n$.
There is also mentioned that $n$ has $\lfloor \log_{2} n \rfloor +1$. Is it true? If yes how can I prove it?

Primo
  • 139
  • 1
  • 1
  • 2
  • 3
    "There is also mentioned that $n$ has $\lfloor \log_2 n\rfloor + 1$".... digits in the base two representation (this missing phrase is incredibly important!). The proof is exactly the same as the decimal case, which you link to already except by replacing $10$'s with $2$'s – JMoravitz Feb 18 '17 at 02:04
  • Technically, digits implies base $10$, you should replace digits by bits to get base $2$. – Michael Burr Feb 18 '17 at 02:10
  • @MichaelBurr and what would you call them in a ternary system? A quaternary system? Digits? Bits? Some other phrase? I have always called them digits in these alternate bases such as base 3, 4, etc... I see little reason to make such a strong distinction between base 2 and every other base. – JMoravitz Feb 18 '17 at 02:16
  • @JMoravitz according to you $2^{d-1}\le n<2^d\implies d=\lfloor\log_{2}n\rfloor+1$ right? but for $n=8, 2^{d-1}\le n<2^d$ is not true, since here $d=1$ – Primo Feb 18 '17 at 02:17
  • Primo, $8$ in binary is $1000_2$, so no, $d=4$. Again, the base two logarithm is used to count how many digits in base 2 there are. The base ten logarithm is used to count how many digits in base ten there are. They are used for different things. – JMoravitz Feb 18 '17 at 02:19
  • Related: http://math.stackexchange.com/questions/335055/what-is-the-relationship-between-base-and-number-of-digits – JMoravitz Feb 18 '17 at 02:27
  • In any base b the number $b^k$ is represented as 1000.... (with k 0's) and $b^{k+1} $ as 1 with k+1 0. So the k+1 digit numbers are precisely all x:$b^k \le x <b^k $ and $k+1 =\log_b x +1$. Not much more to prove. – fleablood Feb 18 '17 at 02:37
  • 1

1 Answers1

2

If $x$ is an $n-$digit number in base B, then

\begin{array}{c} B^{n-1} \le x \lt B^n \\ n-1 \le \log_Bx < n \\ n-1 \le \left\lfloor \log_Bx \right \rfloor < n \\ n \le \left\lfloor \log_Bx \right \rfloor + 1 < n+1 \\ \end{array}

It follows that the number of digits in a base-$B$ number is $\left\lfloor \log_Bx \right \rfloor + 1$.