Template:percent: Difference between revisions
From Thesaurus Inscriptionum Raeticarum
Jump to navigationJump to search
Martin Braun (talk | contribs) No edit summary |
Martin Braun (talk | contribs) No edit summary |
||
Line 6: | Line 6: | ||
[[Category:Text Module]] | [[Category:Text Module]] | ||
</noinclude><includeonly>{{#vardefine: template_percent_n | {{{1|}}} }}{{#vardefine: template_percent_all | {{{2|}}} }}{{#vardefine: template_round | {{{3|2}}} }}{{#ifeq: {{#var: template_percent_n }}||{{#vardefine: template_percent_n | 0 }} }}{{#ifeq: {{#var: template_percent_all }}||{{#vardefine: template_percent_all | 0 }} }}{{#ifexpr: {{#var: template_round }} <1|{{#vardefine: template_round | 0 }} }}{{#ifeq: {{#var: template_percent_all }}|0||{{#vardefine: template_percent_percent | {{#expr: {{#var: template_percent_n }} / {{#var: template_percent_all }} }} }}{{#vardefine: template_percent_percent | {{#expr: {{#var: template_percent_percent }} * 10000 }}}}{{#vardefine: template_percent_percent | {{#expr: {{#var: template_percent_percent }} / 100 }}}}{{#vardefine: template_fraction| {{#sub: {{#explode: {{#var: template_percent_percent }}|.|1}} |0|{{#var: template_round}} }} }}{{#explode: {{#var: template_percent_percent }}|.|0}}{{#ifexpr: {{#var: template_round }} >0|.{{ | </noinclude><includeonly>{{#vardefine: template_percent_n | {{{1|}}} }}{{#vardefine: template_percent_all | {{{2|}}} }}{{#vardefine: template_round | {{{3|2}}} }}{{#ifeq: {{#var: template_percent_n }}||{{#vardefine: template_percent_n | 0 }} }}{{#ifeq: {{#var: template_percent_all }}||{{#vardefine: template_percent_all | 0 }} }}{{#ifexpr: {{#var: template_round }} <1|{{#vardefine: template_round | 0 }} }}{{#ifeq: {{#var: template_percent_all }}|0||{{#vardefine: template_percent_percent | {{#expr: {{#var: template_percent_n }} / {{#var: template_percent_all }} }} }}{{#vardefine: template_percent_percent | {{#expr: {{#var: template_percent_percent }} * 10000 }}}}{{#vardefine: template_percent_percent | {{#expr: {{#var: template_percent_percent }} / 100 }}}}{{#vardefine: template_fraction| {{#sub: {{#explode: {{#var: template_percent_percent }}|.|1}} |0|{{#var: template_round}} }} }}{{#explode: {{#var: template_percent_percent }}|.|0}}{{#ifexpr: {{#var: template_round }} >0|.{{padright: {{#var: template_fraction}}|{{#var: template_round }}|0}}}} %}}</includeonly> |
Latest revision as of 23:01, 15 June 2019
This template serves to calculate and display percentages. It awaits two values: the fraction number and the sum. An optional third value can be given as number of positions after the comma (default is 2).
Examples
- The code
{{percent|5|20}}
will display "25.00 %". - The code
{{percent|5|20|3}}
will display "25.000 %".