This site is supported by donations to The OEIS Foundation.
Template:Ord/doc
From OeisWiki
The {{ord}} OEIS Wiki formatting and function template gives the proper ordinal suffix as superscript (i.e. st, nd, rd or th) by default or on the baseline (i.e. st, nd, rd or th), for an ordinal number.
Contents |
Usage
For ordinal suffix as superscript (default), use
- {{ord|an integer}}
or
- {{ord|an expression evaluating to an integer}}
while for ordinal suffix on the baseline, use (anything other than sup works, though - is recommended)
- {{ord|an integer|-}}
or
- {{ord|an expression evaluating to an integer|-}}
Valid input
An integer (or an expression evaluating to an integer) as first parameter, sup (default) or - as second parameter.
Examples
Examples with valid input
Code Result {{ord|-1021}} −1021st {{ord|-1011}} −1011th {{ord|-1001}} −1001st {{ord|-131}} −131st {{ord|-121}} −121st {{ord|-113}} −113th {{ord|-112}} −112th {{ord|-111}} −111th {{ord|-101}} −101st {{ord|-91}} −91st {{ord|-24}} −24th {{ord|-23}} −23rd {{ord|-22}} −22nd {{ord|-21}} −21st {{ord|-20}} −20th {{ord|-14}} −14th {{ord|-13}} −13th {{ord|-12}} −12th {{ord|-11}} −11th {{ord|-10}} −10th {{ord|-5}} −5th {{ord|-4}} −4th {{ord|-3}} −3rd {{ord|-2}} −2nd {{ord|-1}} −1st {{ord|0}} 0th {{ord|1}} 1st {{ord|2}} 2nd {{ord|3}} 3rd {{ord|4}} 4th {{ord|5}} 5th {{ord|10}} 10th {{ord|11}} 11th {{ord|12}} 12th {{ord|13}} 13th {{ord|14}} 14th {{ord|20}} 20th {{ord|21}} 21st {{ord|22}} 22nd {{ord|23}} 23rd {{ord|24}} 24th {{ord|91}} 91st {{ord|101}} 101st {{ord|111}} 111th {{ord|112}} 112th {{ord|113}} 113th {{ord|121}} 121st {{ord|131}} 131st {{ord|1001}} 1001st {{ord|1011}} 1011th {{ord|1021}} 1021st
If you want the ordinal suffix on the baseline (instead of as superscript), use - as second parameter.
Code Result {{ord|-5|-}} −5th {{ord|-4|-}} −4th {{ord|-3|-}} −3rd {{ord|-2|-}} −2nd {{ord|-1|-}} −1st {{ord|0|-}} 0th {{ord|1|-}} 1st {{ord|2|-}} 2nd {{ord|3|-}} 3rd {{ord|4|-}} 4th {{ord|5|-}} 5th
Examples with expressions evaluating to integers:
{{ord|11^2}}
yields
- 121st
{{ord|{{Fibonacci|4}}}}
yields
- 3rd
Examples with invalid input
Code Result {{ord|24.6}} Ord error: Argument must be an integer. {{ord|third}} Ord error: Argument must be an integer. {{ord}} Ord error: Argument must be an integer.
Code
<noinclude>{{documentation}}</noinclude><includeonly>{{ifint| {{{1|NaN}}}
| {{#ifexpr: ( {{{1}}} ) < 0 | − }}{{#expr: abs ( {{{1}}} ) }}<!--
-->{{#ifeq: {{{2|sup}}} | sup |<sup>}}<!--
-->{{#switch: {{expr| ( ( abs ( {{{1}}} ) ) mod 10 ) + <!--
-->{{#ifexpr: ( ( abs ( {{{1}}} ) ) mod 100 > 10 ) and ( ( abs ( {{{1}}} ) ) mod 100 < 14 ) | 10 | 0 }} }}
| 1 = st
| 2 = nd
| 3 = rd
| th
}}<!--
-->{{#ifeq: {{{2|sup}}} | sup |</sup>}}
| {{error| Ord error: Argument must be an integer. }}
}}</includeonly>
