Spelling of ordinal numbers: Difference between revisions

J
No edit summary
(J)
Line 657:
23456 twenty-three thousand, four hundred and fifty-sixth
8007006005004003 eight quadrillion, seven trillion, six billion, five million, four thousand and third</pre>
 
=={{header|J}}==
 
Here, we follow J's [[j:Vocabulary/Idioms#Ordinal_Number|best practice for ordinal numbers]], which is that 0 is first and 1 is second. This emphasizes the distinction between cardinal numbers like 0 and ordinal numbers like first, accurately represents array indices, and neatly captures a variety of related linguistic issues.
 
Also, we use definitions from the [[Number_names#J|number names task]] and the [[N%27th#J|N'th task]]:
 
<lang J>ord=: {{
((us,suf)1+y) rplc ;:{{)n onest first twond second
threerd third fiveth fifth eightth eighth
}}-.LF
}}</lang>
 
Examples:
 
<lang J> ord 0
first
ord 1
second
ord 2
third
ord 3
fourth
ord 4
fifth
ord 5
sixth
ord 11
twelveth
ord 65
sixty-sixth
ord 100
one hundred first
ord 101
one hundred second
ord 272
two hundred seventy-third
ord 23456
twenty-three thousand four hundred fifty-seventh
ord 8007006005004003
eight quadrillion seven trillion six billion five million four thousand fourth
ord 123
one hundred twenty-fourth
ord 00123.0
one hundred twenty-fourth
ord 1.23e2
one hundred twenty-fourth</lang>
 
=={{header|Java}}==
6,951

edits