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 957523
In Process

The Archive Base Latest Questions

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

What is the most efficient way to convert numeric amount into English words e.g.

  • 0

What is the most efficient way to convert numeric amount into English words

e.g. 12 to twelve
127 to one hundred twenty-seven

  • 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:43:01+00:00Added an answer on May 16, 2026 at 12:43 am

    That didn’t take long. This is an implementation written in Java.

    http://snippets.dzone.com/posts/show/3685

    Code

    public class IntToEnglish {
        static String[] to_19 = { "zero",  "one",   "two",  "three", "four",   "five",   "six",
            "seven", "eight", "nine", "ten",   "eleven", "twelve", "thirteen",
            "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
        static String[] tens  = { "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
        static String[] denom = { "",
            "thousand",     "million",         "billion",       "trillion",       "quadrillion",
            "quintillion",  "sextillion",      "septillion",    "octillion",      "nonillion",
            "decillion",    "undecillion",     "duodecillion",  "tredecillion",   "quattuordecillion",
            "sexdecillion", "septendecillion", "octodecillion", "novemdecillion", "vigintillion" };
    
        public static void main(String[] argv) throws Exception {
            int tstValue = Integer.parseInt(argv[0]);
            IntToEnglish itoe = new IntToEnglish();
            System.out.println(itoe.english_number(tstValue));
            /* for (int i = 0; i < 2147483647; i++) {
                System.out.println(itoe.english_number(i));
            } */
        }
        // convert a value < 100 to English.
        private String convert_nn(int val) throws Exception {
            if (val < 20)
                return to_19[val];
            for (int v = 0; v < tens.length; v++) {
                String dcap = tens[v];
                int dval = 20 + 10 * v;
                if (dval + 10 > val) {
                    if ((val % 10) != 0)
                        return dcap + "-" + to_19[val % 10];
                    return dcap;
                }        
            }
            throw new Exception("Should never get here, less than 100 failure");
        }
        // convert a value < 1000 to english, special cased because it is the level that kicks 
        // off the < 100 special case.  The rest are more general.  This also allows you to
        // get strings in the form of "forty-five hundred" if called directly.
        private String convert_nnn(int val) throws Exception {
            String word = "";
            int rem = val / 100;
            int mod = val % 100;
            if (rem > 0) {
                word = to_19[rem] + " hundred";
                if (mod > 0) {
                    word = word + " ";
                }
            }
            if (mod > 0) {
                word = word + convert_nn(mod);
            }
            return word;
        }
        public String english_number(int val) throws Exception {
            if (val < 100) {
                return convert_nn(val);
            }
            if (val < 1000) {
                return convert_nnn(val);
            }
            for (int v = 0; v < denom.length; v++) {
                int didx = v - 1;
                int dval = new Double(Math.pow(1000, v)).intValue();
                if (dval > val) {
                    int mod = new Double(Math.pow(1000, didx)).intValue();
                    int l = val / mod;
                    int r = val - (l * mod);
                    String ret = convert_nnn(l) + " " + denom[didx];
                    if (r > 0) {
                        ret = ret + ", " + english_number(r);
                    }
                    return ret;
                }
            }
            throw new Exception("Should never get here, bottomed out in english_number");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the most efficient way to convert a System.Collections.Generic.SortedList<string,Contact> into a IEnumerable<Contact> The
What is the most efficient way to get Elastic Map Reduce output into SimpleDB?
What is the quickest most efficient way to search text for words using non-casesensitive
What's the most efficient way to convert an md5 hash to a unique integer
I want convert bool to QString. Whats the most efficient way to do it?,
What is the most efficient way to convert data from nested lists to an
What is the most efficient way to convert a given European formatted date (DD/MM/YY)
What's the most efficient way to convert the output of this function from a
What is the most efficient way to convert a MySQL query to CSV in
What would be the most efficient way to convert SVG to PNG, server side?

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.