[Linux-disciples] Re: Base 10 to base 26
Dylan Thurston
dthurston at barnard.edu
Tue Jun 6 13:56:53 EDT 2006
On Tue, Jun 06, 2006 at 11:06:21AM -0400, Stephen R Laniel wrote:
> 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.
It's easier to start from the bottom. Take N modulo 26; that's the
last letter. Then divide N by 26 and repeat to get the previous
letter until you get to 0.
(This generalizes the algorithm you gave for decimal to binary.)
> I'm just wondering if there's a pre-existing library that
> would do this for me.
Surely, but it's probably just as fast to write it yourself, although
less efficient.
Peace,
Dylan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060606/d80a4c57/attachment.pgp
More information about the Linux-disciples
mailing list