Linear time baseconversion

Ian Kelly ian.g.kelly at gmail.com
Tue Jun 30 12:34:06 EDT 2015


On Tue, Jun 30, 2015 at 10:10 AM, Chris Angelico <rosuav at gmail.com> wrote:
> When there's a simple ratio between the bases, it's fairly
> straight-forward to convert a few digits at a time. Converting base
> 256 into base 64, for instance, can be done by taking three digits and
> yielding four. But within that, you would still need a complete table
> of all sixteen million possibilities, if you want to do the lookup
> table. And that only works when there is that kind of relationship.

You're right. I was thinking that for base 5 to base 7, for instance,
one could read digits in groups of 7, but that doesn't work out; you
can't map any discrete number of base 5 digits to a corresponding
number of base 7 digits.



More information about the Python-list mailing list