converting numbers to words

This is a discussion on converting numbers to words within the C Programming forums, part of the General Programming Boards category; The Magnitude array simply holds the name of the thousand, million, billion... values. If you have the value 12,325,324,255 you ...

  1. #16
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    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).

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 12-21-2007, 12:38 PM
  2. Converting Numbers to Words
    By denizengt in forum C Programming
    Replies: 20
    Last Post: 11-05-2003, 08: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, 05:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21