Thread: converting numbers to words

  1. #16
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    The Magnitude array simply holds the name of the thousand, million, billion... values. If you have the value 12,325,324,255 you can pass the values in a loop,
    first 12 with magnitude 3 (billion)
    second 325 with mag of 2 (million)
    third 324, mag 1 (thousand)
    forth 255 mag 0 (empty value)

    The definition could be:
    Code:
    char *magnitude[] = {"",  // empty for 0-999
                         "thousand",
                         "million",
                         "billion",
                           ...
                        };
    Walt

  2. #17
    Registered User
    Join Date
    May 2003
    Posts
    6
    Just a thought - you may need to do a locale check, as in many countries (such as the UK until a few years ago) a billion is a million million, not a thousand million (aka a 'toy' billion).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 12-21-2007, 01:38 PM
  2. Converting Numbers to Words
    By denizengt in forum C Programming
    Replies: 20
    Last Post: 11-05-2003, 09:19 PM
  3. converting numbers into words
    By Kozam in forum C Programming
    Replies: 2
    Last Post: 09-30-2003, 07:49 AM
  4. C++ program help(converting numbers to english words)
    By bama1 in forum C++ Programming
    Replies: 4
    Last Post: 10-08-2002, 01:17 AM
  5. A (complex) question on numbers
    By Unregistered in forum C++ Programming
    Replies: 8
    Last Post: 02-03-2002, 06:38 PM