Number names/REXX

From Rosetta Code
Revision as of 19:41, 31 January 2013 by rosettacode>Gerard Schildberger (spelled out &, highlighted some numbers. -- ~~~~)

The   $SPELL#   REXX program is included here ──► $SPELL#.REX.
The help for the   $SPELL#   REXX program is included here ──► $SPELL#.HEL.

As I understand the solving of any task, it's OK to use a pre-existing program.
I had first considered taking the original program and ripping out all the good stuff and just solve the
primary task (and optional requirements), but it was taking too much time so I left the program intact.
Not included is the $H program which shows (among other things) the help (documentation).

This REXX program supports:

  • long and short scale   (American and British styles)
  • ordinal numbers and cardinal numbers
  • expressing the number as a YEAR   (1975 would be nineteen seventy-five)
  • decimal points   (6 is different than 6.)
  • decimal fractions
  • numbers with leading zeroes (as well as trailing zeroes)
  • leading signs &nsbp; (+ or -)
  • exponential notation
  • currency symbols
  • adding commas (or whatever) to the output (including blanks)
  • numbers   (American) up to 3,000 digits
  • numbers   (English) up to 6,000 digits
  • numbers with suffixes such as K, M, Gi, etc, and also some common ones as well as factorials
  • user-defineable names for:   signs, decimal point, power, currency symbols, zero (digit), etc.

The program has a pretty hefty prologue which determines   (among other things):

  • the operating system (and maybe the type)
  • the name of the REXX program: it's filename, filetype, filemode (or path, if you will)
  • the access-name to acquire environmental variables
  • if EBCDIC or ASCII system
  • which REXX (or KEXX) is being used
  • the name of the program (command) to clear the terminal screen
  • if appropriate, invokes $H to show the help/logic flow/sample uses/or program author

I'm still working on the program to reduce the amount of names by programmatically generating any amount of number-names (instead of having a fixed amount of names in text form).

Also note that there appears not to be a consensus on the names of some numbers:

  • nonillion   is also called noventillion
  • noven*     are also named novem*
  • septen*   are also named septem*
  • ses*         are also named sex*
  • tre*           also named tres*


The $SPELL# REXX program makes use of $T REXX program which is used to display text and/or write the text to a file.
The $T REXX program is included here ──► $T.REX.
The help for the $T REXX program is included here ──► $T.HEL.

The $SPELL# REXX program makes use of $ERR REXX program which is used to display error messages (via $T).
The $ERR REXX program is included here ──► $ERR.REX.
The help for the $ERR REXX program is included here ──► $ERR.HEL.

Some older REXXes don't have a changestr bif, so one is included here ──► CHANGESTR.REX.

output

Output when using the input of: 373 ordinal

three hundred seventy-third

Output when using the input of: 373

three hundred seventy-three

Output when using the input of: +45

plus forty-five

Output when using the input of: 1989 asYear

nineteen eighty-nine

Output when using the input of: -12.79

minus twelve point seven nine

Output when using the input of: $119.63

one hundred nineteen dollars and sixty-three cents

Output when using the input of: 3456T

three quadrillion four hundred fifty-six trillion

Output when using the input of: 4Ki

four thousand ninety-six

Output when using the input of: 6!

seven hundred twenty

Output when using the input of: 10dozen

one hundred twenty

Output when using the input of: 70000000000000...(3,000 zeroes total)

seven octononagintanongentillion