Difference between revisions of "Template:Rnd"

From MINR.ORG WIKI
(copying a template for nice rounding, i.e. trailing zeros & no conversion to E notation using {{subst:sigfig/rnd}})
 
(a few adjustments + explanation)
Line 1: Line 1:
{{#ifexpr:{{{3}}}<-3|{{Sigfig/mil
+
<includeonly>{{#ifexpr:{{{2}}}<-3|{{rnd/+
 
|{{{1}}}
 
|{{{1}}}
|(-({{{3}}}))mod3
+
|(-({{{2}}}))mod3
|{{#switch:{{#expr:{{{3}}}}}
+
|{{#switch:{{#expr:{{{2}}}}}
 
| -3| -4| -5=000
 
| -3| -4| -5=000
 
| -6| -7| -8=000000
 
| -6| -7| -8=000000
Line 23: Line 23:
 
|-57|-58|-59=000000000000000000000000000000000000000000000000000000000
 
|-57|-58|-59=000000000000000000000000000000000000000000000000000000000
 
|-60|-61|-62=000000000000000000000000000000000000000000000000000000000000
 
|-60|-61|-62=000000000000000000000000000000000000000000000000000000000000
}}}}|{{sigfig/nil|{{#expr:{{{1}}}round{{{3}}}}}|{{{3}}}}}}}
+
}}}}|{{rnd/-|{{#expr:{{{1}}}round{{{2}}}}}|{{{2}}}}}}}</includeonly><noinclude>This template rounds {{{1}}} to {{{2}}} decimal places (goes the other way for negatives), includes trailing zeros & avoids E notation.</noinclude>

Revision as of 18:44, 21 September 2007

This template rounds {{{1}}} to {{{2}}} decimal places (goes the other way for negatives), includes trailing zeros & avoids E notation.