Difference between revisions of "Template:0expr"

From blackwiki
Jump to navigation Jump to search
blackwiki>Waldyrious
(document / indent the code)
m (29 revisions imported)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
<includeonly>{{#if:{{{1|}}}|<!-- If an unnamed parameter is passed...
+
<includeonly>{{#ifeq: {{#expr: {{{1}}} < 0}} | 1 | {{#expr: {{{1}}}}} | {{#invoke:BaseConvert|convert|n={{#expr: {{{1}}} }}|base=10|width=2}}}}</includeonly><noinclude>{{documentation}}</noinclude>
            -->{{#ifexpr: 0 <= ({{#expr:{{{1}}}+0}}) and ({{#expr:{{{1}}}+0}}) < 10|<!-- ...and it is a number between 0 and 9...
 
              -->0<!-- ...add a padding zero
 
            -->}}{{#expr:{{{1}}}}}<!--
 
          -->}}</includeonly><noinclude>{{documentation}}</noinclude>
 

Latest revision as of 09:04, 30 September 2020

Template documentation[view] [edit] [history] [purge]

Usage

Evaluate expression, add leading zero to non-negative result < 10.

{{0expr| {{CURRENTDOW}} }} = 06 for {{CURRENTDOW}} = 6

{{ #expr:{{ CURRENTDOW}}}} = 6, for details see the talk page.

Code Result
{{0expr|-1}} -1
{{0expr|123/100}} 01.2299999999
{{0expr|1+9}} 10
{{0expr|not 10}} 00
{{0expr|1=(7<=8)*9}} 09
{{0expr|(7<=8)*9|2+3}} 05

Template:When in namespace