I am currently faced with the following problem.
Suppose I have a number $N$ in base $a$, and let $N_0, N_1, \cdots, N_n$ be the digits of said number in that base. It is also given that $N_i < b \space \forall \space i$. I want to build the number $M$ in base $b$, such as $N_i = M_i \space \forall \space i$. Of course, I can compute $M$ as $M = \sum_{i} N_i b^i$.
My question is: can we do any better, computationally? Especially given that we know $n$, the number of digits in both bases, is there any trick we can use to do this more efficiently?
I am especially interested in any solution that doesn't involve "unpacking" the digits of $N$ (that is, computing the values of $N_i$). This is because i will be implementing this conversion in computer program that heavily relies on this, and the modulo operation is generally rather slow (compared to sums, multiplications or bitwise binary operators).
Thank you for your time, and forgive me if I wasn't clear at any point!
(also forgive me if the tags may not be appropriate, but I don't really know how to tag this question)