Number names/REXX: Difference between revisions

From Rosetta Code
Content added Content deleted
m (removed a blank line in the section header. -- ~~~~.)
m (alligned some text.)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The   '''$SPELL#'''   REXX program is included here ──► [[$SPELL#.REX]].
The full source of the   '''$SPELL#'''   REXX program is included here ──►   [[$SPELL.REX|$SPELL#.REX]].
<br>The help for the &nbsp; '''$SPELL#''' &nbsp; REXX program is included here ──► [[$SPELL#.HEL]].
<br>The full help for the&nbsp; &nbsp; &nbsp; '''$SPELL#''' &nbsp; REXX program is included here ──► &nbsp; [[$SPELL.HEL|$SPELL#.HEL]].

<br><br>As I understand the solving of any task, it's OK to use a pre-existing program.
As I understand the solving of any Rosetta Code task, it's OK to use a pre-existing computer language program.
<br>I had first considered taking the original program and ripping out all the good stuff and just solve the

<br>primary task (and optional requirements), but it was taking too much time so I left the program intact.
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 (whole) REXX program intact.
<br>Not included is the '''$H''' program which shows (among other things) the help (documentation).

Not included here is the &nbsp; '''$H''' &nbsp; REXX program which shows (among other things) various forms of help &nbsp; (program documentation, program/help author, sample uses, or logic flow). <br><br>


This REXX program supports:
This REXX program supports:


* long & short scale &nbsp; (American and British styles)
* long and short scale &nbsp; (American and British styles)
* ordinal numbers and cardinal numbers
* ''ordinal numbers'' &nbsp; and &nbsp; ''cardinal numbers''
* expressing the number as a YEAR &nbsp; ('''1975''' would be '''nineteen seventy-five''')
* expressing the number as a (calendar) &nbsp; ''year'' &nbsp; &nbsp; ('''1975''' would be '''nineteen seventy-five''')
* decimal points &nbsp; (6 is different than 6.)
* decimal points &nbsp; (<big>'''6'''</big> &nbsp; is different than &nbsp; <big>'''6.'''</big>)
* decimal fractions
* decimal fractions
* numbers with leading zeroes (as well as trailing zeroes)
* numbers with leading zeroes (as well as trailing zeroes)
* leading signs &nsbp; ('''+''' or '''-''')
* leading signs &nbsp; (<big>'''+'''</big> or <big>'''-'''</big>)
* exponential notation
* exponential notation
* currency symbols
* currency symbols
* adding commas (or whatever) to the output (including blanks)
* adding commas (or whatever) to the output (including blanks)
* numbers &nbsp; (American) up to 3,000 digits
* numbers &nbsp; (American) roughly up to 3,000 digits
* numbers &nbsp; (English) up to 6,000 digits
* numbers &nbsp; (English) &nbsp; &nbsp; roughly up to 6,000 digits
* numbers with suffixes such as '''K''', '''M''', '''Gi''', etc, and also some common ones as well as factorials
* numbers with metric suffixes, namely:
** '''K M G T P E Z Y X W V U'''
* user-defineable names for: &nbsp; signs, decimal point, power, currency symbols, zero (digit), etc.
* numbers with binary suffixes, namely:
** '''Ki Mi Gi Ti Pi Ei Zi Yi Xi Wi Vi Ui'''
** the above suffixes can be combined: &nbsp; '''44MM''' &nbsp; (44 million million)
* numbers with some common suffixes such as:
** '''dozens'''
** '''gross'''
** '''greatgross'''
** '''pairs'''
** '''scores'''
** '''googols'''
** or any suitable abbreviation of the above
* numbers expressed as a factorial &nbsp; (such as &nbsp; '''100!''').
* user-definable names for:
** signs &nbsp; &nbsp; ('''-6''' &nbsp; ''could be'' &nbsp; expressed as &nbsp; '''negatory six''')
** decimal point &nbsp; &nbsp; ('''2.4''' &nbsp; ''could be'' &nbsp; expressed as &nbsp; '''two boink four''')
** power &nbsp; (the power of ten that the number is being raised to)
** currency symbols
** zero (the digit)
** blanks
** a value of zero
* numbers may have commas but they aren't enunciated


The program has a pretty hefty prologue which determines &nbsp; (among other things):
The program has a pretty hefty prologue which determines &nbsp; (among other things):
Line 27: Line 50:
* the operating system (and maybe the type)
* the operating system (and maybe the type)
* the name of the REXX program: it's filename, filetype, filemode (or path, if you will)
* the name of the REXX program: it's filename, filetype, filemode (or path, if you will)
* the access-name to acquire environmental variables
* the access-name used to acquire environmental variables' values
* if EBCDIC or ASCII system
* if '''EBCDIC''' or '''ASCII''' system
* which REXX (or KEXX) is being used
* which REXX (or KEXX) is being used
* the name of the program (command) to clear the terminal screen
* the name of the program (command) used to clear the terminal screen
* if appropriate, invokes <code>$H</code> to show the help/logic flow/sample uses/or program author
* if appropriate, invokes &nbsp; '''$H''' &nbsp; to show the help, logic flow, sample uses, or 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).
I'm still working on the REXX program to reduce the amount of names by programmatically generating any amount of number-names &nbsp; (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:
Also note that there appears not to be a consensus on the names of some numbers:
Line 42: Line 65:
* '''tre*''' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; also named '''tres*'''
* '''tre*''' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; also named '''tres*'''


<br>The '''$SPELL#''' REXX program makes use of '''$T''' REXX program which is used to display text and/or write the text to a file.
<br>The &nbsp; '''$SPELL#''' &nbsp; REXX program makes use of &nbsp; '''$T''' &nbsp; REXX program which is used to display text and/or write the text to a file.
<br>The '''$T''' REXX program is included here ──► [[$T.REX]].
<br>The &nbsp; '''$T''' &nbsp; REXX program is included here &nbsp; ──► &nbsp; [[$T.REX]].
<br>The help for the '''$T''' REXX program is included here ──► [[$T.HEL]].
<br>The help for the &nbsp; '''$T''' &nbsp; REXX program is included here ──► &nbsp; [[$T.HEL]].
<br><br>The '''$SPELL#''' REXX program makes use of '''$ERR''' REXX program which is used to display error messages (via '''$T''').
<br><br>The &nbsp; '''$SPELL#''' &nbsp; REXX program makes use of &nbsp; '''$ERR''' &nbsp; REXX program which is used to display error messages (via '''$T''').
<br>The '''$ERR''' REXX program is included here ──► [[$ERR.REX]].
<br>The &nbsp; '''$ERR''' &nbsp; REXX program is included here &nbsp; ──► &nbsp; &nbsp; [[$ERR.REX]].
<br>The help for the '''$ERR''' REXX program is included here ──► [[$ERR.HEL]].
<br>The help for the &nbsp; '''$ERR''' &nbsp; REXX program is included here &nbsp; ──► &nbsp; [[$ERR.HEL]].
<br><br>Some older REXXes don't have a '''changestr''' bif, so one is included here ──► [[CHANGESTR.REX]].
<br><br>Some older REXXes don't have a &nbsp; '''changestr''' &nbsp; BIF, so one is included here &nbsp; ──► &nbsp; [[CHANGESTR.REX]].
<br><br>
<br><br>


==output==
==output==
Output when using the input of: <tt>373 ordinal</tt>
Output when using the input of: &nbsp; <tt> 373 ordinal </tt>
three hundred seventy-third
three hundred seventy-third


Output when using the input of: <tt>373</tt>
Output when using the input of: &nbsp; <tt> 373 </tt>
three hundred seventy-three
three hundred seventy-three


Output when using the input of: <tt>+45</tt>
Output when using the input of: &nbsp; <tt> +45 </tt>
plus forty-five
plus forty-five


Output when using the input of: <tt>1989 asYear</tt>
Output when using the input of: &nbsp; <tt> 1989 asYear </tt>
nineteen eighty-nine
nineteen eighty-nine


Output when using the input of: <tt>-12.79</tt>
Output when using the input of: &nbsp; <tt> -12.79 </tt>
minus twelve point seven nine
minus twelve point seven nine


Output when using the input of: <tt>$119.63</tt>
Output when using the input of: &nbsp; <tt> $119.63 </tt>
one hundred nineteen dollars and sixty-three cents
one hundred nineteen dollars and sixty-three cents


Output when using the input of: <tt>3456T</tt>
Output when using the input of: &nbsp; <tt> 3456T </tt>
three quadrillion four hundred fifty-six trillion
three quadrillion four hundred fifty-six trillion


Output when using the input of: <tt>4Ki</tt>
Output when using the input of: &nbsp; <tt> 4Ki </tt>
four thousand ninety-six
four thousand ninety-six


Output when using the input of: <tt>6!</tt>
Output when using the input of: &nbsp; <tt> 6! </tt>
seven hundred twenty
seven hundred twenty


Output when using the input of: <tt>10dozen</tt>
Output when using the input of: &nbsp; <tt> 10dozen </tt>
one hundred twenty
one hundred twenty


Output when using the input of: <tt>70000000000000...</tt>(3,000 zeroes total)
Output when using the input of: &nbsp; <tt> 70000000000000... </tt> &nbsp; &nbsp; (3,000 zeroes total)
seven octononagintanongentillion
seven octononagintanongentillion

Latest revision as of 09:59, 27 October 2020

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

As I understand the solving of any Rosetta Code task, it's OK to use a pre-existing computer language 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 (whole) REXX program intact.

Not included here is the   $H   REXX program which shows (among other things) various forms of help   (program documentation, program/help author, sample uses, or logic flow).

This REXX program supports:

  • long and short scale   (American and British styles)
  • ordinal numbers   and   cardinal numbers
  • expressing the number as a (calendar)   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   (+ or -)
  • exponential notation
  • currency symbols
  • adding commas (or whatever) to the output (including blanks)
  • numbers   (American) roughly up to 3,000 digits
  • numbers   (English)     roughly up to 6,000 digits
  • numbers with metric suffixes, namely:
    • K M G T P E Z Y X W V U
  • numbers with binary suffixes, namely:
    • Ki Mi Gi Ti Pi Ei Zi Yi Xi Wi Vi Ui
    • the above suffixes can be combined:   44MM   (44 million million)
  • numbers with some common suffixes such as:
    • dozens
    • gross
    • greatgross
    • pairs
    • scores
    • googols
    • or any suitable abbreviation of the above
  • numbers expressed as a factorial   (such as   100!).
  • user-definable names for:
    • signs     (-6   could be   expressed as   negatory six)
    • decimal point     (2.4   could be   expressed as   two boink four)
    • power   (the power of ten that the number is being raised to)
    • currency symbols
    • zero (the digit)
    • blanks
    • a value of zero
  • numbers may have commas but they aren't enunciated

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 used to acquire environmental variables' values
  • if EBCDIC or ASCII system
  • which REXX (or KEXX) is being used
  • the name of the program (command) used to clear the terminal screen
  • if appropriate, invokes   $H   to show the help, logic flow, sample uses, or author.

I'm still working on the REXX 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