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

  • SEARCH
  • Home
  • 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 8381327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:40:31+00:00 2026-06-09T16:40:31+00:00

I want to convert a integer to alphabetic equivalent like ordered list in HTML.

  • 0

I want to convert a integer to alphabetic equivalent like ordered list in HTML.

<ol type="a">

I tried to convert a base 10 number to a base 26 with a-z digits.

But that’s not what I wanted.

IN     WANT        GET      
-----------------------
1   =>  a       <=  a
2   =>  b       <=  b
3   =>  c       <=  c
4   =>  d       <=  d
5   =>  e       <=  e
6   =>  f       <=  f
7   =>  g       <=  g
8   =>  h       <=  h
9   =>  i       <=  i
10  =>  j       <=  j
11  =>  k       <=  k
12  =>  l       <=  l
13  =>  m       <=  m
14  =>  n       <=  n
15  =>  o       <=  o
16  =>  p       <=  p
17  =>  q       <=  q
18  =>  r       <=  r
19  =>  s       <=  s
20  =>  t       <=  t
21  =>  u       <=  u
22  =>  v       <=  v
23  =>  w       <=  w
24  =>  x       <=  x
25  =>  y       <=  y
26  =>  z       <=  az
27  =>  aa      <=  aa
28  =>  ab      <=  ab
29  =>  ac      <=  ac

private final static char[] digits = {
'0' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 
'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 
'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 
's' , 't' , 'u' , 'v' , 'w' , 'x' , 'y' , 'z'
};

private static String numberToAlphaNumeric(long i, int radix) {

    char[] buf = new char[65];
    int charPos = 64;
    boolean negative = (i < 0);
    if (!negative) {
        i = -i;
    }
    while (i <= -radix) {
        buf[charPos--] = digits[(int)(-(i % radix))];
        i = i / radix;
    }
    buf[charPos] = digits[(int)(-i)];
    if (negative) { 
        buf[--charPos] = '-';
    }
    return new String(buf, charPos, (65 - charPos));
}

public static String numberToAlphaNumeric(long number) {
    ArrayList<String> list = new ArrayList<String>();
    for( int j = 0; list.size() != number; j++ ) {
        String alpha = numberToAlphaNumeric( j, digits.length );
        if(!alpha.contains( "0" )) {
            list.add( alpha );
        }
    }
    return list.get( list.size()-1 );
}

My 2nd Idea:

If I extend a new leading symbol to the digits and convert my number to a base 27 number,
I have the new Symbol in every carry over which is wrong and I can filter these out.

This is very inefficient and ugly, but I have no more ideas. What is the common way?

  • 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-06-09T16:40:32+00:00Added an answer on June 9, 2026 at 4:40 pm

    This is the basic algorithm. Use a StringBuffer if you need to be more efficient:

      public static String getAlpha(int num) {
    
        String result = "";
        while (num > 0) {
          num--; // 1 => a, not 0 => a
          int remainder = num % 26;
          char digit = (char) (remainder + 97);
          result = digit + result;
          num = (num - remainder) / 26;
        }
    
        return result;
      }
    

    Another way to do this would be to convert to base 26, and then add 97 to each character in the string you get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert an integer into its character equivalent based on the alphabet.
I want to convert a floating point user input into its integer equivalent. I
I want to convert number from char * format to 32 bit integer int32_t,
I want convert the storage of a floating point number to an integer (the
I want to convert a number that is in PRTime format (a 64-bit integer
I want to convert the integer to floating number with precision 2. ie. -
I want to convert a hex string to a 32 bit signed integer in
I want to convert a column of numbers to numeric, but there are certain
I want to convert a number to hex and store the result in a
I want to convert plaintext to link for an input I have. The HTML

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.