Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Abs: Difference between revisions

Template page
Shane (talk | contribs)
No edit summary
Shane (talk | contribs)
No edit summary
 
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>

Latest revision as of 16:06, 2 August 2006

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