[Linux-disciples] Re: Base 10 to base 26

Stephen R Laniel steve at laniels.org
Tue Jun 6 11:06:21 EDT 2006


On Tue, Jun 06, 2006 at 11:00:07AM -0400, Stephen R Laniel wrote:
> For silly reasons, I need to be able to convert a number to
> a letter -- e.g., 26 = Z, 27 = AA, etc. Is there a quick,
> easy way to do a change of base between base 10 and base 26?

I think it's easy enough just to say: all numbers N are

N = a_k * 26^k + a_{n-1} * 26^{k-1} + ... + a_1 * 26 + a_0 .

Then find the highest k* such that 26^{k*} is not larger than N,
and the highest a_{k*} such that a_{k*} * 26{k*} is not
larger than N. Subtract a_{k*} * 26^{k*} from N, and repeat
until the remainder is 0. Something like that.

I'm just wondering if there's a pre-existing library that
would do this for me.

-- 
Stephen R. Laniel
steve at laniels.org
Cell: +(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060606/6595d930/attachment.pgp


More information about the Linux-disciples mailing list