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

Editing Template:Roundup

Template page
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
<includeonly>{{zero|{{#expr:{{#ifexpr:{{abs|{{{1}}}}}-({{abs|{{{1}}}}} round {{{2|0}}})<=0|({{{1}}}) round {{{2|0}}}|(({{{1}}}) round {{{2|0}}}) + ({{{1}}})/{{abs|{{{1}}}}}/{{pow|10|{{{2|0}}}}}}}}}}}</includeonly><noinclude>This template rounds up a numeric value to a limited number of decimal places.
<includeonly>{{zero|{{#expr:{{#ifexpr: {{abs|{{{1}}}}}-({{abs|{{{1}}}}} round {{{2|0}}})<=0|({{{1}}}) round {{{2|0}}}|(({{{1}}}) round {{{2|0}}}) + ({{{1}}})/{{abs|{{{1}}}}}/{{pow|10|{{{2|0}}}}}}}}}}}</includeonly><noinclude>{{Template documentation}}


; Usage
This template rounds up a numeric value to a limited number of decimal places.
* {{tlp|{{PAGENAME}}|''value''}}
 
* {{tlp|{{PAGENAME}}|''value''|''decimals''}}
; Usage<nowiki>:</nowiki>
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki></tt>''value''<tt><nowiki>}}</nowiki></tt>
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki></tt>''value''<tt><nowiki>|</nowiki></tt>''decimals''<tt><nowiki>}}</nowiki></tt>
* Both parameters can be any valid numeric expression.
* Both parameters can be any valid numeric expression.
* The ''decimals'' parameter defaults to 0 and is rounded to the nearest integer.
* The ''decimals'' parameter defaults to 0 and is rounded to the nearest integer.
* ''decimals'' can be negative to round up to a multiple of a power of ten.
* ''decimals'' can be negative to round up to a multiple of a power of ten.
* If ''decimals'' is not between -20 and 20, the ''value'' is returned without rounding.
* If ''decimals'' is not between -20 and 20, the ''value'' is returned without rounding.
; Examples<nowiki>:</nowiki>
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|3.14159|3}}</nowiki></tt> = {{{{PAGENAME}}|3.14159|3}}
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|0|3}}</nowiki></tt> = {{{{PAGENAME}}|0|3}} (should be 0, not 0.001)
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-0.00031|3}}</nowiki></tt> = {{{{PAGENAME}}|-0.00031|3}} (should be -0.001, not 0)
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-3.14159|3}}</nowiki></tt> = {{{{PAGENAME}}|-3.14159|3}}
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|0|0}}</nowiki></tt> = {{{{PAGENAME}}|0|0}} (should be 0, not 1)
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-0.9|0}}</nowiki></tt> = {{{{PAGENAME}}|-0.9|0}} (should be -1, not 0)
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|314159|-3}}</nowiki></tt> = {{{{PAGENAME}}|314159|-3}}
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|0|-3}}</nowiki></tt> = {{{{PAGENAME}}|0|-3}} (should be 0, not 1000)
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-514.15|-3}}</nowiki></tt> = {{{{PAGENAME}}|-514.15|-3}} (should be -1000, not 0)
* <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|-514159|-3}}</nowiki></tt> = {{{{PAGENAME}}|-514159|-3}}
; Note<nowiki>:</nowiki>
* <tt><nowiki>{{</nowiki>Ceil<nowiki>|</nowiki></tt>''value''<tt><nowiki>}}</nowiki></tt> is equivalent to <tt><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|</nowiki></tt>''value''<tt><nowiki>}}</nowiki></tt>.
; See also<nowiki>:</nowiki>
* [[Template:Rounddown]]


[[Category:Mathematical templates|{{PAGENAME}}]]
[[Category:Mathematical templates|{{PAGENAME}}]]
[[Category:Templates using ParserFunctions|{{PAGENAME}}]]
[[Category:Templates using ParserFunctions|{{PAGENAME}}]]
</noinclude>
</noinclude>

To edit this page, please enter the words that appear below in the box (more info):

Refresh
Cancel Editing help (opens in new window)

  [] · [[]] · [[|]] · {{}} · · “” ‘’ «» ‹› „“ ‚‘ · ~ | ° &nbsp; · ± × ÷ ² ³ ½ · §
     [[Category:]] · [[:File:]] · [[Special:MyLanguage/]] · <code></code> · <nowiki></nowiki> <code><nowiki></nowiki></code> · <syntaxhighlight></syntaxhighlight> · <includeonly></includeonly> · <noinclude></noinclude> · #REDIRECT[[]] · <translate></translate> · <languages/> · {{#translation:}} · <tvar|></> · {{DEFAULTSORT:}} · <categorytree></categorytree> · <div style="clear:both;"></div> <s></s>


Your changes will be visible immediately.
  • For testing, please use the sandbox instead.
  • On talk pages, please sign your comment by typing four tildes (~~~~).

Template used on this page: