1
$\begingroup$

I know a similar question was asked before, but I wanted to know if this can be extended to any number system by a generic formula.

For example, given a number X in number system A, how many digits would it have in number system B? I'm looking for a sort of universal formula in terms of X, A and B.

Thanks

$\endgroup$
1
$\begingroup$

As J. M. said in a comment to the question you ask, an integer $X$ has $\lfloor 1+\log_B X\rfloor$ base-$B$ digits. Going from base $A$ to base $B$ the number of digits is multiplied by $\frac{\log A}{\log B}$ but that is approximate due to the 1 and the floor function.

$\endgroup$
  • $\begingroup$ I apologize if this seems trivial but I'm unable to use it in an example. Let's say I have a decimal number of 100 digits and I want to find how many bits it would have. Would that be (approximately) 100 * log(2)/(log 10)? $\endgroup$ – David Feb 23 '11 at 15:00
  • $\begingroup$ I had a typo, now fixed. It should be 100*log(10)/log(2). You can check with smaller numbers. A three digit number ranges from 100 to 999. In base 2 this ranges from 7 to 10 bits. And log (10)/log(2) is about 1/.30103=3.32 $\endgroup$ – Ross Millikan Feb 23 '11 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.