Task

Show how to spell out a number in English.

You can use a preexisting implementation or roll your own, but you should support inputs up to at least one million (or the maximum value of your language's default bounded integer type, if that's less).

Support for inputs other than positive integers (like zero, negative integers, and floating-point numbers) is optional.



Related task

   Spelling of ordinal numbers.


make "numbers {one two three four five six seven eight nine ten 
     eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen}
 
make "tens {twenty thirty forty fifty sixty seventy eighty ninety}@2
 
make "thou [[] thousand million billion trillion]		; expand as desired
 
to to.english.thou :n :thou
  if :n = 0    [output []]
  if :n < 20   [output sentence item :n :numbers  first :thou]
  if :n < 100  [output (sentence item int :n/10 :tens
                                 to.english.thou modulo :n 10 [[]]
                                 first :thou)]
  if :n < 1000 [output (sentence item int :n/100 :numbers
                                 "hundred
                                 to.english.thou modulo :n 100 [[]]
                                 first :thou)]
  output (sentence to.english.thou int :n/1000 butfirst :thou
                   to.english.thou modulo :n 1000 :thou)
end
 
to to.english :n
  if :n = 0 [output "zero]
  if :n > 0 [output to.english.thou :n :thou]
  [output sentence "negative to.english.thou minus :n :thou]
end
 
print to.english 1234567   ; one million two hundred thirty four thousand five hundred sixty seven