Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 958811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:55:29+00:00 2026-05-16T00:55:29+00:00

I have a method that converts an int to a base60 string (using 0-9,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:55:29+00:00Added an answer on May 16, 2026 at 12:55 am

    One way of doing this could be:

        public static function fromBase60(value:String):Number {
            var result:Number = 0;
            var targetBase:uint = 60;
            var digitValue:int = 0;
            for(var i:int = 0, j:int = value.length - 1; j >= 0; i++,j--) {
                digitValue = reverseMap[value.charAt(j)];
                result += Math.pow(targetBase,i) * digitValue; 
            }
            return result;
        }
    

    Looks like you have an array that maps numbers (digits) to characters, so you could build a reverse map upfront and make the lookup easier. With some code like this:

        // add this code to your class
        private static var reverseMap:Object = {};
    
        private static function buildReverseMap():void {
            var len:int = baseChars.length;
            for(var i:int = 0; i < len; i++) {
                reverseMap[baseChars[i]] = i;
            }
        }
    
        // initialize the reverse map
        {
            buildReverseMap();
        }
    

    Edit

    Alternative implementation, based on algorithm posted by Tom Sirgedas. This avoids calling Math.pow, though I doubt you’ll note much difference in practice (performance-wise):

        public static function fromBase60(value:String):Number {
            var result:Number = 0;
            var targetBase:uint = 60;
            var digitValue:int = 0;
            var len:int = value.length;
            for(var i:int = 0; i < len; i++) {
                digitValue = reverseMap[value.charAt(i)];
                result = result * targetBase + digitValue; 
            }
            return result;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 501k
  • Answers 501k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's nothing built in, but you could use the filter()… May 16, 2026 at 2:12 pm
  • Editorial Team
    Editorial Team added an answer If your database is still in full recovery mode, the… May 16, 2026 at 2:12 pm
  • Editorial Team
    Editorial Team added an answer If you set the DeletePaths property in the file explorer's… May 16, 2026 at 2:12 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I need to create an Objective-C method that converts an int into a byte
I have a Base64 string that's been gzipped in .NET and I would like
I have a string that I Gzip on the server and download to a
I have an object, lets call it UnSerializableObject, that I can't and change that
I have a 3rd party method that returns an old-style ArrayList, and I want
I need to convert a String representation of a nested List back to a
I have a the following dictionary: IDictionary<int, IList<MyClass>> myDictionary and I am wanting to
I have a fair few images that I'm loading into a ListBox in my
I'm curious as to the best way to convert a double to an int.
I think this is a relatively simple question, but I don't precisely know what's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.