Click here to Skip to main content
15,920,687 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Converting numbers into English Pin
_Maxxx_26-Sep-13 15:07
professional_Maxxx_26-Sep-13 15:07 
GeneralRe: Converting numbers into English Pin
R. Giskard Reventlov27-Sep-13 4:56
R. Giskard Reventlov27-Sep-13 4:56 
GeneralRe: Converting numbers into English Pin
_Maxxx_28-Sep-13 1:00
professional_Maxxx_28-Sep-13 1:00 
GeneralRe: Converting numbers into English Pin
R. Giskard Reventlov28-Sep-13 5:45
R. Giskard Reventlov28-Sep-13 5:45 
GeneralRe: Converting numbers into English Pin
Dan Sutton25-Sep-13 15:55
Dan Sutton25-Sep-13 15:55 
GeneralRe: Converting numbers into English Pin
_Maxxx_25-Sep-13 17:31
professional_Maxxx_25-Sep-13 17:31 
GeneralRe: Converting numbers into English Pin
Dan Sutton25-Sep-13 19:51
Dan Sutton25-Sep-13 19:51 
GeneralRe: Converting numbers into English Pin
_Maxxx_25-Sep-13 20:11
professional_Maxxx_25-Sep-13 20:11 
You had to go no further than our very own CP[^]

or I stole this from StuckOverflow...
C#
public static string NumberToWords(int number)
{
    if (number == 0)
        return "zero";

    if (number < 0)
        return "minus " + NumberToWords(Math.Abs(number));

    string words = "";

    if ((number / 1000000) > 0)
    {
        words += NumberToWords(number / 1000000) + " million ";
        number %= 1000000;
    }

    if ((number / 1000) > 0)
    {
        words += NumberToWords(number / 1000) + " thousand ";
        number %= 1000;
    }

    if ((number / 100) > 0)
    {
        words += NumberToWords(number / 100) + " hundred ";
        number %= 100;
    }

    if (number > 0)
    {
        if (words != "")
            words += "and ";

        var unitsMap = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
        var tensMap = new[] { "zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

        if (number < 20)
            words += unitsMap[number];
        else
        {
            words += tensMap[number / 10];
            if ((number % 10) > 0)
                words += "-" + unitsMap[number % 10];
        }
    }

    return words;
}

MVVM # - I did it My Way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011

.\\axxx
(That's an 'M')

GeneralRe: Converting numbers into English Pin
Dan Sutton26-Sep-13 4:57
Dan Sutton26-Sep-13 4:57 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 13:46
mvePIEBALDconsult26-Sep-13 13:46 
GeneralRe: Converting numbers into English Pin
_Maxxx_26-Sep-13 15:07
professional_Maxxx_26-Sep-13 15:07 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 16:10
mvePIEBALDconsult26-Sep-13 16:10 
GeneralRe: Converting numbers into English Pin
Marc A. Brown26-Sep-13 2:11
Marc A. Brown26-Sep-13 2:11 
GeneralRe: Converting numbers into English Pin
Dan Sutton26-Sep-13 4:58
Dan Sutton26-Sep-13 4:58 
GeneralRe: Converting numbers into English Pin
_Maxxx_26-Sep-13 15:12
professional_Maxxx_26-Sep-13 15:12 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 16:29
mvePIEBALDconsult26-Sep-13 16:29 
GeneralRe: Converting numbers into English Pin
User 5924125-Sep-13 15:31
User 5924125-Sep-13 15:31 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult25-Sep-13 18:22
mvePIEBALDconsult25-Sep-13 18:22 
GeneralRe: Converting numbers into English Pin
Mark_Wallace25-Sep-13 21:34
Mark_Wallace25-Sep-13 21:34 
GeneralRe: Converting numbers into English Pin
Dan Sutton26-Sep-13 4:55
Dan Sutton26-Sep-13 4:55 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 13:48
mvePIEBALDconsult26-Sep-13 13:48 
GeneralRe: Converting numbers into English Pin
NormDroid25-Sep-13 23:53
professionalNormDroid25-Sep-13 23:53 
GeneralRe: Converting numbers into English Pin
Dan Sutton26-Sep-13 4:55
Dan Sutton26-Sep-13 4:55 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 13:53
mvePIEBALDconsult26-Sep-13 13:53 
GeneralRe: Converting numbers into English Pin
PIEBALDconsult26-Sep-13 13:48
mvePIEBALDconsult26-Sep-13 13:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.