I have a method that converts an int
to a base60 string
(using 0-9, a-z, and A-Z chars), but can't work out how to convert it back again. Here is my method for converting base10 to base60:
public static function toBase60(value:Number):String
{
var targetBase:uint = 60;
value = value.toString().split('.')[0];
var digits:Array = new Array();
while (value > 0)
{
digits.push(baseChars[value % targetBase]);
value = Math.floor(value / targetBase);
}
var myResult:String = digits.reverse().join('');
return myResult;
}
Works well. But how do I get the base60 string back into a base10 int? I happen to be using ActionScript 3, but really, examples in any programming language, generic explanations or sudo code would be great.