# ordinal

The file builtins\ordinal.e (an autoinclude) contains a small collection of (English only) ordinal number handling routines.
string suffix = ord(atom n) - returns "st", "nd", "rd", or "th". n<=0 always returns "th".
string res = ordinal(atom n, bool bJustSpell=false) - returns "first", "second", etc, or "one", "two", etc if bJustSpell is true.
string res = ordinant(atom n) - returns ["minus "] "never", "once", "twice", "three times", etc.

> The ordinal() routine handles numbers up to at least one quadrillion (1015), as well as fractions, to at most ten decimal places.
> One trillion is 1012, one billion is 109, this never returns "millard", and cannot as yet be configured to return such.
> For negative numbers the result is simply prefixed with "minus ", otherwise identical to the corresponding positive number result.

These routines are fully supported by pwa/p2js.

### Example:

Copy

    for p=-2 to 11 do
        integer i = iff(p<=4?p:power(p,3))
        printf(1,"The %d%s or %s number is %s.\n",{i,ord(i),ordinal(i),ordinal(i,true)})
    end for
    printf(1,"PI is %s\n",{ordinal(PI,true)})
    printf(1,"1.23 is %s\n",{ordinal(1.23,true)})
    printf(1,"e occurs %s in feed",{ordinant(2)})
    -- Output:
    -- The -2th or minus second number is minus two.
    -- The -1th or minus first number is minus one.
    -- The 0th or zeroth number is zero.
    -- The 1st or first number is one.
    -- The 2nd or second number is two.
    -- The 3rd or third number is three.
    -- The 4th or fourth number is four.
    -- The 125th or one hundred and twenty-fifth number is one hundred and twenty-five.
    -- The 216th or two hundred and sixteenth number is two hundred and sixteen.
    -- The 343rd or three hundred and forty-third number is three hundred and forty-three.
    -- The 512th or five hundred and twelfth number is five hundred and twelve.
    -- The 729th or seven hundred and twenty-ninth number is seven hundred and twenty-nine.
    -- The 1,000th or one thousandth number is one thousand.
    -- The 1,331st or one thousand, three hundred and thirty-first number is one thousand, three hundred and thirty-one.
    -- PI is three point one four one five nine two six five three five
    -- 1.23 is one point two three
    -- e occurs twice in feed