Given an integer $N$, we can find that it has $ \lfloor\log_bN\rfloor+1$ digits in base $b$.
But what if $N$ is not in base $10$, but is in base $a$?

Can we calculate the number of digits $N$ written in base $a$ has in base $b$, but without converting $N_a$ to $N_{10}$ (its decimal representation)?

What I have tried:

If we have a case like, for example, where we have $1234567_8$ and $b=2$, then we can solve $2^x=8 \to x=3$ and know that each digit of base $8$ will take three digits to write in base $2$ (including trailing zeroes). But the last one should not have trailing zeroes, so we need to evaluate the last digit by itself, which is $1$, and see it takes only one digit in base $2$ as well. Thus, our number written in octal will have $3\times 6 +1=19$ digits in binary. But what if $x$ is not an integer?

I've thus tried to round the values to the nearest integer and put this method into a formula. In general, we follow this approach:

Since we can't evaluate (convert to base $10$) the $N_a$, we can count how many digits it has.
Also, I need to "cheat" a bit by evaluating only the last digit of the number $N_a$.

If $n$ is the number of digits of $N_a$ and $d$ is the last digit, then $N_b$ has digits: $$(n-1)[\log_ba]+\lfloor\log_bd\rfloor+1$$

($[x]$ rounds the number to the nearest integer, and $\lfloor x\rfloor$ is the floor function.)

How can we check/prove whether this expression is always exactly correct or not? I've tried only handful of examples and not sure how to fully check this. (it is correct if $x$ is an integer, the rounding is the only thing that bothers me)

Is there a better way to calculate/write solution to this problem?

  • 2
    $\begingroup$ f(N) = f(N) no matter what format we write N in. So $\log_b 27$ will be $\log_b 27$ whether we write $27$ ans $27_{10}$ or $33_8$ or $42-5$ or $3^3$ or $2^4*2^3+2+1$ or as $XXVII$. $\endgroup$
    – fleablood
    Oct 7, 2017 at 17:13
  • $\begingroup$ Thing is knowing what N is in base 10 only helps us calculate log_b 1N in the most vague and approximate way. $\log_b 5246 \approx \log_b 5*10^3 = \log_b 5 + 3\log_b 10$. So $\log_b qrstu_a \approx \log_b 5 + 4\log_b a$. If you know the method we use for the less significant digits it will be the exact same but with $a$ instead of $10$. $\endgroup$
    – fleablood
    Oct 7, 2017 at 17:21
  • $\begingroup$ So HOW do you calculate $\log_b N_{10}$? if you don't know the answer to that we can not ask the question. If you do know the answer than the answer is the exact same-- except replace ever use of 10 with a. $\endgroup$
    – fleablood
    Oct 7, 2017 at 17:30
  • $\begingroup$ @fleablood I perhaps should've been more clear, as you seem to have misunderstood my question (As the other two people upvoting your comment did too). My idea was finding the answer but under the condition that you can't evaluate $X_b$ directly. As seen in the post, I try to estimate the numbers based on amount of digits relative to the base. Thus, we actually do not know that $27_{10}=33_8$, as you've tried to illustrate. $\endgroup$
    – Vepir
    Oct 28, 2017 at 14:57

1 Answer 1


When the number $N$ is a variable with an arbitrary value, the number of base-$b$ digits is indeed $\lfloor \log_b N\rfloor+1$.

If $N$ is a concrete number written in base $a$ with $n$ digits, its value lies in $[a^{n-1},a^n-1]$ and the number of base-$b$ digits is in

$$\big[\lfloor \log_b a^{n-1}\rfloor+1,\lfloor \log_b(a^n-1)\rfloor+1\big]$$ which is most of the time

$$\big[\lfloor (n-1)\log_ba\rfloor+1,\lfloor n\log_ba\rfloor+1\big].$$

  • $\begingroup$ Off-by-one: You should use $\lfloor \log_b N\rfloor+1 ,$ try $N=7$ or $N=10$ with base $10.$ $\endgroup$ Oct 7, 2017 at 18:06
  • $\begingroup$ @gammatester: yep, I forgot the $+1$ everywhere. Fixing. $\endgroup$
    – user65203
    Oct 7, 2017 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .