Difference between revisions of "Template:ordinal"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
m
m
Line 1: Line 1:
βˆ’
<includeonly>{{formatnum:{{#expr:{{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}}}}}|{{#if:{{#pos:{{{2|}}}|R}}|R}}}} }}{{#if:{{#pos:{{{2|}}}|S}}|<sup>}}{{#ifexpr:10<=abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 100 and abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 100<=20|th|{{#switch:{{#expr:abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 10}}|1=st|2=nd|3=rd|th}}}}{{#if:{{#pos:{{{2|}}}||S}}|</sup>}}</includeonly><noinclude>
+
<includeonly>{{formatnum: {{#expr: {{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}} }} |{{#if:{{#pos:{{{2|}}}|R}}|R}} }}{{#if:{{#pos:{{{2|}}}|S}}|<sup>}}{{#ifexpr:10<=abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 100 and abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 100<=20|th|{{#switch:{{#expr:abs({{formatnum:{{#if:{{{1|}}}|{{{1|}}}|0}}|R}}) mod 10}}|1=st|2=nd|3=rd|th}}}}{{#if:{{#pos:{{{2|}}}||S}}|</sup>}}</includeonly><noinclude>
  
 
This properly formats the given number as an abbreviated ordinal number in English.
 
This properly formats the given number as an abbreviated ordinal number in English.

Revision as of 04:37, 30 January 2025


This properly formats the given number as an abbreviated ordinal number in English.

Usage

{{ordinal|number|flags}}

  • number is the number to be formatted
    - Negative numbers get formatted as positive numbers with an negative sign added to the front of the number.
    - 0 gets formatted as "Zeroth".
  • flags indicates flags for the format of the output
    - If "R" is in flags, the output is formatted without commas.
    - If "S" is in flags, the output is formatted with the ordinal indicators not in superscripts.
    - Flags can be combined in any order

Examples

  • {{ordinal|1}}
produces
1st
  • {{ordinal|0002}}
produces
2nd
  • {{ordinal|0}}
produces
{ordinal|0}
  • {{ordinal|-3}}
produces
-3rd
  • {{ordinal|123456789}}
produces
123,456,789th
  • {{ordinal|983,675,911}}
produces
983,675,911th
  • {{ordinal|123456|S}}
produces
123,456th
  • {{ordinal|314159|R}}
produces
314159th
  • {{ordinal|-271828|RS}}
produces
-271828th
Examples of ordinal numbers in English
Number Ordinal Number Ordinal Number Ordinal
0 0th 10 10th 20 20th
1 1st 11 11th 21 21st
2 2nd 12 12th 22 22nd
3 3rd 13 13th 23 23rd
4 4th 14 14th 24 24th
5 5th 15 15th 25 25th
6 6th 16 16th 26 26th
7 7th 17 17th 27 27th
8 8th 18 18th 28 28th
9 9th 19 19th 29 29th