Sep 19, 2011, 4:54:59 PM9/19/11
to Building Skills Books
Check Amount Writing.
Translate a number into the English phrase.
This example algorithm fragment is only to get you started. This shows
how to pick off the digits from
the right end of a number and assemble a resulting string from the
left end of the string.
Note that the right-most two digits have special names, requiring some
additional cases above and
beyond the simplistic loop shown below. For example, 291 is “two
hundred ninety one”, where 29 is
“twenty nine”. The word for “2” changes, depending on the context.
As a practical matter, you should analyze the number by taking off
three digits at a time, the expression
‘(number % 1000)’ does this. You would then format the three digit
number with words like “million”,