Template:Decimals: Difference between revisions

From Homecoming Wiki
Jump to navigation Jump to search
imported>Eabrace (historical)
m (cross your fingers...)
(Extension:NumberFormat not installed, rewriting in vanilla #expr)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<includeonly>{{#ifexpr: {{{2}}}<=0|{{#expr:{{{1}}} round {{{2}}}}}|{{#expr:{{{1}}} round {{#ifexpr: {{{2}}}>12|12|{{{2}}}}}}}{{#ifexpr: ({{{2}}}>=1)|{{#ifexpr: (({{{1}}} round 0)=({{{1}}} round {{{2}}}))|.0|}}{{#ifexpr: ({{{2}}}>=2)|{{#ifexpr: (({{{1}}} round 1)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=3)|{{#ifexpr: (({{{1}}} round 2)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=4)|{{#ifexpr: (({{{1}}} round 3)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=5)|{{#ifexpr: (({{{1}}} round 4)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=6)|{{#ifexpr: (({{{1}}} round 5)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=7)|{{#ifexpr: (({{{1}}} round 6)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=8)|{{#ifexpr: (({{{1}}} round 7)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=9)|{{#ifexpr: (({{{1}}} round 8)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=10)|{{#ifexpr: (({{{1}}} round 9)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=11)|{{#ifexpr: (({{{1}}} round 10)=({{{1}}} round {{{2}}}))|0|}}{{#ifexpr: ({{{2}}}>=12)|{{#ifexpr: (({{{1}}} round 11)=({{{1}}} round {{{2}}}))|0|}}}}}}}}}}}}}}}}}}}}}}}}}}}}</includeonly><noinclude>
<includeonly>{{#expr:{{{1|0}}} round {{{2|2}}}}}</includeonly><noinclude>{{Documentation}}</noinclude>
{{Documentation}}
</noinclude>

Latest revision as of 03:03, 8 May 2022

[edit] [purge] Documentation

Usage

{{Decimals|number|decimals}}

Examples

  • {{Decimals|1234|0}} yields 1234
  • {{Decimals|1234|1}} yields 1234
  • {{Decimals|1234|2}} yields 1234
  • {{Decimals|9/8|5}} yields 1.125
  • {{Decimals|1/3|15}} yields 0.33333333333333
  • {{Decimals|1/33|7}} yields 0.030303
  • {{Decimals|0.006|1}} yields 0