Difference between revisions of "Template:Cardinal to word/0 to 999"

From blackwiki
Jump to navigation Jump to search
imported>SimonTrew
(Encode space.)
imported>SimonTrew
(Use error template)
Line 1: Line 1:
 
<includeonly><!--  
 
<includeonly><!--  
 
-->{{#ifexpr:({{{1}}} < 0) or ({{{1}}} > 999) or (trunc {{{1}}} <> {{{1}}})<!--
 
-->{{#ifexpr:({{{1}}} < 0) or ({{{1}}} > 999) or (trunc {{{1}}} <> {{{1}}})<!--
   -->|(Error in {{tlx|Cardinal to word/0 to 999}}: value "{{{1}}}" is not a natural number in the range 0 to 999)<!--
+
   -->|{{error|{{tlx|Cardinal to word/0 to 999}}: value "{{{1}}}" is not a natural number in the range 0 to 999}}<!--
 
   -->|{{#ifexpr:{{{1}}} < 100<!--
 
   -->|{{#ifexpr:{{{1}}} < 100<!--
 
       -->|{{Cardinal to word/0 to 99|{{{1}}}|zero{{#ifeq:{{{zero|}}}|{{{zero|-}}}||x}}={{{zero|}}}}}<!--
 
       -->|{{Cardinal to word/0 to 99|{{{1}}}|zero{{#ifeq:{{{zero|}}}|{{{zero|-}}}||x}}={{{zero|}}}}}<!--

Revision as of 12:38, 1 July 2010

50px Template documentation[view] [edit] [history] [purge]

Converts a natural number in the range 0 to 999 into a word in the English language.

Usage

{{Cardinal to word/0 to 999|natural[|zero=zero][|us=on]}}

natural: Required. A natural number in the range 0 to 999.

zero: Optional. The value to use when the number is 0. Default is "zero". Can be made empty or, for example, "no", "none" or "nought", as appropriate for the context.

us: Optional. If the value is "on", the output of numbers does not include "and" to separate hundreds from smaller values. This accords with American usage as described at English numerals.

Examples

{{Cardinal to word/0 to 999|0|zero=not a sausage}}
{{Cardinal to word/0 to 999|30}}
{{Cardinal to word/0 to 999|100}}
{{Cardinal to word/0 to 999|235|us=on}}
{{Cardinal to word/0 to 999|999}}
{{Cardinal to word/0 to 999|-1}}

produces:

not a sausage 
thirty
one hundred
two hundred thirty-five
nine hundred and ninety-nine
{{Cardinal to word/0 to 999}}: value "-1" is not a natural number in the range 0 to 999

See also