An algorithm for converting a base-10 number to a base-N number.

Posted by roja on Stack Overflow See other posts from Stack Overflow or by roja
Published on 2010-05-24T01:34:43Z Indexed on 2010/05/24 1:40 UTC
Read the original article Hit count: 292

Filed under:
|
|
|

Guys,

I am looking for a way to convert a base-10 number into a base-N number where N can be large. Specifically i am looking at converting to base-85 and back again. Does anyone know a simple algorithm to perform the conversion? Ideally it would provide something like:

to_radix(83992, 85) -> [11, 53, 12]

Any ideas are appreciated!

Roja

© Stack Overflow or respective owner

Related posts about ruby

Related posts about algorithm