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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:29:33+00:00 2026-05-13T22:29:33+00:00

I’m using .net. Is there some code somewhere that can change $11,456.50 -> eleven

  • 0

I’m using .net. Is there some code somewhere that can change

$11,456.50 -> eleven thousand four hundred fifty six and 50/100 Dollars

I can do it myself, but don’t want to rewrite something that’s already there.

  • 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-13T22:29:34+00:00Added an answer on May 13, 2026 at 10:29 pm

    Here is an unpolished first shot. No error checking at all and the code does not handle the fractional part. And it is almost untested. With BigInteger the method can handle values up to 10^66 - 1 or about 219 bits easily extended by adding more entries to M2.

    public static String NumberToText(Decimal n)
    {
        if (n < 0)
        {
            return "minus " + NumberToText(-n);
        }
        else if (n == 0)
        {
            return M1[n];
        }
        else
        {
            var scale = 0;
            var parts = new List<String>();
    
            while (n != 0)
            {
                if (n % 1000 != 0)
                {
                    parts.Add(String.Format("{0} {1}", NumberToTextSmaller1000(n % 1000), M2[scale]));
                }
    
                n = Math.Floor(n / 1000);
                scale++;
            }
    
            parts.Reverse();
    
            return String.Join(", ", parts.ToArray());
        }
    }
    
    private static String NumberToTextSmaller1000(Decimal n)
    {
        var pattern = (n < 100) ? "{2}" : (n % 100 == 0) ? "{0} {1}" : "{0} {1} {2}";
    
        return String.Format(pattern, M1[Math.Floor(n / 100)], M1[100], NumberToTextSmaller100(n % 100));
    }
    
    private static String NumberToTextSmaller100(Decimal n)
    {
        return (0 <= n) && (n < 20)) || (n % 10 == 0) 
            ? M1[n] 
            : String.Format("{0}-{1}", M1[n - n % 10], M1[n % 10];
    }
    
    private static readonly IDictionary<Decimal, String> M1 = new Dictionary<Decimal, String>
        {
            { 0, "zero" }, { 1, "one" }, { 2, "two" }, { 3, "three" },
            { 4, "four" }, { 5, "five" }, { 6, "six" }, { 7, "seven" },
            { 8, "eight" }, { 9, "nine" }, { 10, "ten" }, { 11, "eleven" },
            { 12, "twelve" }, { 13, "thirteen" }, { 14, "fourteen" },
            { 15, "fifteen" }, { 16, "sixteen" }, { 17, "seventeen" },
            { 18, "eighteen" }, { 19, "nineteen" }, { 20, "twenty" },
            { 30, "thirty" }, { 40, "forty" }, { 50, "fifty" }, { 60, "sixty" },
            { 70, "seventy" }, { 80, "eighty" }, { 90, "ninety" }, { 100, "hundred" }
        };
    
    // The leading spaces are important.
    private static readonly IDictionary<Decimal, String> M2 = new Dictionary<Decimal, String>
        {
            { 0, String.Empty }, { 1, " thousand" }, { 2, " million" }, { 3, " billion" },
            { 4, " trillion" }, { 5, " quadrillion" }, { 6, " quintillion" },
            { 7, " sextillion" }, { 8, " septillion" }, { 9, " octillion" },
            { 10, " nonillion" }, { 11, " decillion" }, { 12, " undecillion" },
            { 13, " duodecillion" }, { 14, " tredecillion" }, { 15, " quattuordecillion" },
            { 16, " quindecillion" }, { 17, " sexdecillion" }, { 18, " septendecillion" },
            { 19, " octodecillion" }, { 20, " novemdecillion" }, { 21, " vigintillion" }
        };
    

    Called on Decimal.MaxValue the method returns the following.

    seventy-nine octillion, two hundred twenty-eight septillion, one hundred sixty-two sextillion, five hundred fourteen quintillion, two hundred sixty-four quadrillion, three hundred thirty-seven trillion, five hundred ninety-three billion, five hundred forty-three million, nine hundred fifty thousand, three hundred thirty-five

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer something like this? using boost::lambda; X2 x; transform(..., (bind(std::make_pair<X,X2>, _1,… May 14, 2026 at 3:23 pm
  • Editorial Team
    Editorial Team added an answer Reading these other StackOverflow answers may help you! before start… May 14, 2026 at 3:23 pm
  • Editorial Team
    Editorial Team added an answer If the domain of the session cookie is set to… May 14, 2026 at 3:23 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

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.