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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:37:10+00:00 2026-05-10T13:37:10+00:00

Is there an efficient method of converting an integer into the written numbers, for

  • 0

Is there an efficient method of converting an integer into the written numbers, for example:

string Written = IntegerToWritten(21); 

would return ‘Twenty One’.

Is there any way of doing this that doesn’t involve a massive look-up table?

  • 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. 2026-05-10T13:37:11+00:00Added an answer on May 10, 2026 at 1:37 pm

    This should work reasonably well:

    public static class HumanFriendlyInteger {     static string[] ones = new string[] { '', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine' };     static string[] teens = new string[] { 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen' };     static string[] tens = new string[] { 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety' };     static string[] thousandsGroups = { '', ' Thousand', ' Million', ' Billion' };      private static string FriendlyInteger(int n, string leftDigits, int thousands)     {         if (n == 0)         {             return leftDigits;         }          string friendlyInt = leftDigits;          if (friendlyInt.Length > 0)         {             friendlyInt += ' ';         }          if (n < 10)         {             friendlyInt += ones[n];         }         else if (n < 20)         {             friendlyInt += teens[n - 10];         }         else if (n < 100)         {             friendlyInt += FriendlyInteger(n % 10, tens[n / 10 - 2], 0);         }         else if (n < 1000)         {             friendlyInt += FriendlyInteger(n % 100, (ones[n / 100] + ' Hundred'), 0);         }         else         {             friendlyInt += FriendlyInteger(n % 1000, FriendlyInteger(n / 1000, '', thousands+1), 0);             if (n % 1000 == 0)             {                 return friendlyInt;             }         }          return friendlyInt + thousandsGroups[thousands];     }      public static string IntegerToWritten(int n)     {         if (n == 0)         {             return 'Zero';         }         else if (n < 0)         {             return 'Negative ' + IntegerToWritten(-n);         }          return FriendlyInteger(n, '', 0);     } } 

    (Edited to fix a bug w/ million, billion, etc.)

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

Sidebar

Ask A Question

Stats

  • Questions 184k
  • Answers 184k
  • 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 Hey, I've seen some odd behavior when pulling XML columns… May 12, 2026 at 4:46 pm
  • Editorial Team
    Editorial Team added an answer 1) I'd say that standard practice is to set up… May 12, 2026 at 4:46 pm
  • Editorial Team
    Editorial Team added an answer Apply the scipy.sign function to every cell in the matrix.… May 12, 2026 at 4:46 pm

Related Questions

I'm constantly running up against this when writing queries with LINQ-to-XML: the Value property
Given a list of assorted length words, what is the best way to find
I have an array of lists of numbers, e.g.: [0] (0.01, 0.01, 0.02, 0.04,
I have a SQL Server 2008 query SELECT TOP 10 * FROM T WHERE

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.