|
|
Line 1: |
Line 1: |
| <includeonly>{{if:{{{1|}}}|{{ifexpr:({{{1}}})>=0|{{expr:({{{1}}})}}|{{expr:-({{{1}}})}}}}|}}</includeonly><noinclude> | | <includeonly>{{#if:{{{1|}}}|{{#ifexpr:({{{1}}})>=0|{{#expr:({{{1}}})}}|{{#expr:-({{{1}}})}}}}|}}</includeonly><noinclude> |
| This template evaluates its numeric parameter and returns its [[Wikipedia:absolute value|absolute value]]. If the parameter is empty or missing, it returns an empty string. The parameter may also be a numeric expression that will be evaluated before testing its sign. | | This template evaluates its numeric parameter and returns its [[Wikipedia:absolute value|absolute value]]. If the parameter is empty or missing, it returns an empty string. The parameter may also be a numeric expression that will be evaluated before testing its sign. |
|
| |
|
| ; Syntax<nowiki>:</nowiki> | | ; Syntax |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>''value''<nowiki>}}</nowiki></tt>
| | * {{tlp|{{PAGENAME}}|''value''}} |
| | |
| ; Examples with a simple number<nowiki>:</nowiki>
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>100<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|100}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.1<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0.1}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0.1<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-0.1}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-100<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-100}}.
| |
| | |
| ; Examples where the parameter is evaluated<nowiki>:</nowiki>
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>01<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|01}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>00<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|00}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0.}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>0.0<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|0.0}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-0<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-0}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>3-4<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|3-4}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki>-4*2<nowiki>}}</nowiki></tt> = {{{{PAGENAME}}|-4*2}}.
| |
| | |
| ; Examples with a empty (or missing) parameter<nowiki>:</nowiki>
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|}}</nowiki></tt> = {{{{PAGENAME}}|}}.
| |
| : <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>}}</nowiki></tt> = {{{{PAGENAME}} }}.
| |
|
| |
|
| | [[Category:Mathematical templates|{{PAGENAME}}]] |
| [[Category:Templates using ParserFunctions|{{PAGENAME}}]] | | [[Category:Templates using ParserFunctions|{{PAGENAME}}]] |
| [[Category:Mathematical templates|{{PAGENAME}}]]
| |
| </noinclude> | | </noinclude> |
This template evaluates its numeric parameter and returns its absolute value. If the parameter is empty or missing, it returns an empty string. The parameter may also be a numeric expression that will be evaluated before testing its sign.
- Syntax