Template:Ifnumber
Jump to navigation
Jump to search
Usage[edit source]
Returns {{{2|1}}} if {{{1}}} is numeric & {{{3|0}}} otherwise.
Examples[edit source]
code | result |
---|---|
{{Ifnumber|1}} |
1 |
{{Ifnumber|one}} |
0 |
{{Ifnumber|}} |
0 |
{{Ifnumber|1|a number|not a number}} |
a number |
{{Ifnumber|one|a number|not a number}} |
not a number |
{{Ifnumber|1000|a number|not a number}} |
a number |
{{Ifnumber|10.00|a number|not a number}} |
a number |
{{Ifnumber|1,000|a number|not a number}} |
not a number |
{{Ifnumber|1,000.50|a number|not a number}} |
not a number |
{{Ifnumber|99 balloons|a number|not a number}} |
not a number |
{{Ifnumber|99.9999e10|a number|not a number}} |
a number |
{{Ifnumber|{{{val|6.B2C}}}|number|value "{{{val|6.B2C}}}" not numeric}} | value "6.B2C" not numeric |
Notes[edit source]
This template will not recognize formatted numbers, which is by design since formatted numbers will break expression parsers. To remove the formatting from a number, you can wrap the number first in {{formatnum: number |R}}.
code | result |
---|---|
{{Ifnumber|1,000.50|a number|not a number}} | not a number |
{{Ifnumber|{{formatnum:1,000.50|R}}|a number|not a number}} | a number |
See also[edit source]
- {{isnumeric}}
External links[edit source]
- Template:Ifnumber at Wikipedia, the free Terran encyclopedia that anyone can edit.
The above documentation is transcluded from Template:Ifnumber/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |