Difference between revisions of "Template:ordinal"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
m
m
Line 22: Line 22:
 
* <code><nowiki>{{ordinal|0}}</nowiki></code>
 
* <code><nowiki>{{ordinal|0}}</nowiki></code>
 
:: produces
 
:: produces
: <code>{ordinal|0}</code>
+
: <code>{{ordinal|0}}</code>
* <code><nowiki>{{ordinal|-3}}</nowiki></code>
+
* <code><nowiki>{{ordinal|-00003}}</nowiki></code>
 
:: produces
 
:: produces
: <code>{{ordinal|-3}}</code>
+
: <code>{{ordinal|-000003}}</code>
 
* <code><nowiki>{{ordinal|123456789}}</nowiki></code>
 
* <code><nowiki>{{ordinal|123456789}}</nowiki></code>
 
:: produces
 
:: produces
Line 35: Line 35:
 
:: produces
 
:: produces
 
: <code>{{ordinal|123456|S}}</code>
 
: <code>{{ordinal|123456|S}}</code>
* <code><nowiki>{{ordinal|314159|R}}</nowiki></code>
+
* <code><nowiki>{{ordinal|00,314,159|R}}</nowiki></code>
 
:: produces
 
:: produces
: <code>{{ordinal|314,159|R}}</code>
+
: <code>{{ordinal|00,314,159|R}}</code>
 
* <code><nowiki>{{ordinal|-271828|RS}}</nowiki></code>
 
* <code><nowiki>{{ordinal|-271828|RS}}</nowiki></code>
 
:: produces
 
:: produces

Revision as of 04:41, 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
0th
  • {{ordinal|-00003}}
produces
-3rd
  • {{ordinal|123456789}}
produces
123,456,789th
  • {{ordinal|983,675,911}}
produces
983,675,911th
  • {{ordinal|123456|S}}
produces
123,456th
  • {{ordinal|00,314,159|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