Template:round: 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 3: | Line 3: | ||
=== Examples === | === Examples === | ||
*The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|172.58}}</nowiki></code> will display "{{{{PAGENAME}}|172.58}}". | *The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|172.58}}</nowiki></code> will display "{{ {{PAGENAME}}|172.58}}". | ||
*The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|172.58|0.1}}</nowiki></code> will display "{{{{PAGENAME}}|172.58|0.1}}". | *The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|172.58|0.1}}</nowiki></code> will display "{{ {{PAGENAME}}|172.58|0.1}}". | ||
*The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|172.58|25}}</nowiki></code> will display "{{{{PAGENAME}}|172.58|25}}". | *The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|172.58|25}}</nowiki></code> will display "{{ {{PAGENAME}}|172.58|25}}". | ||
*The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|172.58|100}}</nowiki></code> will display "{{{{PAGENAME}}|172.58|100}}". | *The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>|172.58|100}}</nowiki></code> will display "{{ {{PAGENAME}}|172.58|100}}". | ||
*The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>}}</nowiki></code> will display "{{{{PAGENAME}}}}". | *The code <code><nowiki>{{</nowiki>{{PAGENAME}}<nowiki>}}</nowiki></code> will display "{{ {{PAGENAME}} }}". | ||
[[Category:Text Module]] | [[Category:Text Module]] | ||
</noinclude><includeonly>{{#vardefine: template_round_n | {{{1|0}}} }}{{#vardefine: template_round_p | {{{2|1}}} }}{{#vardefine: template_round_o | {{#expr: {{#var: template_round_n }} / {{#var: template_round_p }} }} }}{{#vardefine: template_round_r | {{#expr: floor {{#var: template_round_o }} }} }}{{#ifexpr: {{#var: template_round_o }} - {{#var: template_round_r }} > 0.5 | {{#vardefine: template_round_r | {{#expr: {{#var: template_round_r }} + 1 }} }} }}{{#vardefine: template_round_r | {{#expr: {{#var: template_round_r }} * {{#var: template_round_p }} }} }}{{#vardefine: template_round_k | {{#len: {{#explode: {{#var: template_round_p }}|.|1}} }} }}{{#ifexpr: {{#var: template_round_k }} > 0|{{#explode: {{#var: template_round_r }}|.|0}}.{{#pad: {{#explode: {{#var: template_round_r }}|.|1}}|{{#var: template_round_k }}|0|right }}|{{#var: template_round_r }} }}</includeonly> | </noinclude><includeonly>{{#vardefine: template_round_n | {{{1|0}}} }}{{#vardefine: template_round_p | {{{2|1}}} }}{{#vardefine: template_round_o | {{#expr: {{#var: template_round_n }} / {{#var: template_round_p }} }} }}{{#vardefine: template_round_r | {{#expr: floor {{#var: template_round_o }} }} }}{{#ifexpr: {{#var: template_round_o }} - {{#var: template_round_r }} > 0.5 | {{#vardefine: template_round_r | {{#expr: {{#var: template_round_r }} + 1 }} }} }}{{#vardefine: template_round_r | {{#expr: {{#var: template_round_r }} * {{#var: template_round_p }} }} }}{{#vardefine: template_round_k | {{#len: {{#explode: {{#var: template_round_p }}|.|1}} }} }}{{#ifexpr: {{#var: template_round_k }} > 0|{{#explode: {{#var: template_round_r }}|.|0}}.{{#pad: {{#explode: {{#var: template_round_r }}|.|1}}|{{#var: template_round_k }}|0|right }}|{{#var: template_round_r }} }}</includeonly> |
Latest revision as of 23:58, 14 September 2013
This template serves to round numbers.
Examples
- The code
{{round|172.58}}
will display "173". - The code
{{round|172.58|0.1}}
will display "172.{{#pad: 6|1|0|right }}". - The code
{{round|172.58|25}}
will display "175". - The code
{{round|172.58|100}}
will display "200". - The code
{{round}}
will display "0".