|
|
Line 1: |
Line 1: |
| <includeonly>{{#ifeq: {{lc:{{{1|}}}}} | e | {{{3|0}}} | {{#iferror:{{#expr:{{{1|}}}*0}}|{{{3|0}}}|{{{2|1}}}}} }}</includeonly><noinclude> | | <includeonly>{{#ifeq: {{lc:{{{1|}}}}} | e | {{{3|0}}} | {{#iferror:{{#expr:{{{1|}}}*0}}|{{{3|0}}}|{{{2|1}}}}} }}</includeonly><noinclude> |
| === Usage ===
| | [https://en.wikipedia.org/w/index.php?title=Template:Ifnumber/doc wikipedia.org/w/index.php?title=Template:Ifnumber/doc] |
| Returns 1 if the value is numeric and 0 otherwise.
| |
| | |
| ==Examples==
| |
| <table class="wikitable">
| |
| <tr><th>code</th><th>result</th></tr>
| |
| {{template example row|1}}
| |
| {{template example row|one}}
| |
| {{template example row|<nowiki />}}
| |
| {{template example row|e<>pi}}
| |
| {{template example row|1|a number|not a number}}
| |
| {{template example row|one|a number|not a number}}
| |
| {{template example row|1000|a number|not a number}}
| |
| {{template example row|10.00|a number|not a number}}
| |
| {{template example row|1,000|a number|not a number}}
| |
| {{template example row|1,000.50|a number|not a number}}
| |
| {{template example row|99 balloons|a number|not a number}}
| |
| {{template example row|99.9999e10|a number|not a number}}
| |
| {{template example row|−123|a number|not a number}}
| |
| {{template example row|(456)|a number|not a number}}
| |
| {{template example row|e|a number|not a number}}
| |
| <tr><td><code>
| |
| <nowiki>{{Ifnumber|{{val|123|5}}|number|value "{{val|123|5}}" not numeric}}</nowiki> </code></td><td> {{Ifnumber|{{val|123|5}}|number|value "{{val|123|5}}" not numeric}}</td>
| |
| </tr>
| |
| </table>
| |
| | |
| ==Notes==
| |
| 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 <nowiki>{{formatnum:</nowiki> ''number'' <nowiki>|R}}</nowiki>.
| |
| | |
| <table class="wikitable">
| |
| <tr><th>code</th><th>result</th></tr>
| |
| <tr><td><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|1,000.50|a number|not a number}}</nowiki></td><td>{{ {{BASEPAGENAME}}|1,000.50|a number|not a number}}</td></tr>
| |
| <tr><td><nowiki>{{</nowiki>{{BASEPAGENAME}}<nowiki>|{{formatnum:1,000.50|R}}|a number|not a number}}</nowiki></td><td>{{ {{BASEPAGENAME}}|{{formatnum:1,000.50|R}}|a number|not a number}}</td></tr>
| |
| </table>
| |
| | |
| == See also ==
| |
| * {{tl|isnumeric}}
| |
|
| |
|
| [[Category:Help templates]] | | [[Category:Help templates]] |
| </noinclude> | | </noinclude> |