Template:round: Difference between revisions

From Thesaurus Inscriptionum Raeticarum
Jump to navigationJump to search
No edit summary
 
No edit summary
Line 10: Line 10:


[[Category:Text Module]]
[[Category:Text Module]]
</noinclude><includeonly>{{#vardefine: template_round_n | {{{1|0}}} }}{{#vardefine: template_round_p | {{{2|0}}} }}{{#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>

Revision as of 23:57, 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 "{{{{PAGENAME}}}}".