Template:Percent/doc

From Terraria Mods Wiki
Jump to navigation Jump to search

This template is used to apply a standard format to percentage values in an input string.

Usage

{{ percent | <input string> }}

First unnamed parameter

The input string. The template will detect and process the following:

  • Percentages (natural and decimal, positive and negative)
  • Decimals (positive and negative)
  • Fractions (positive and negative)
  • Any other valid {{#expr:}} string

Notes

  • Decimals, fractions, and the results of other expressions will be rounded to two decimal places.
  • If the input string does not consist of any of the valid formats outlined above, a percentage sign will be simply be added to it.
  • The template is faster if the percentage sign is omitted. Therefore, if the input (or the result of it, if it is an expression) is purely numerical, the percentage sign should be left out.

Examples

Code Result
{{percent|100%}} 100%
{{percent|16.67   %}} 16.67  %
{{percent|50% {{note|paren=y|Hardmode}} / {{expert|12.5%}}}} 50% (Hardmode) / 12.5%
{{percent|1–3%}} 1–3%
{{percent|1.25–6.67%}} 1.25–6.67%
{{percent|0.12}} 12%
{{percent|2}} 200%
{{percent|1/8}} 12.5%
{{percent|22/39}} 56.41%
{{percent|(35/11 mod 2) - (10^-2 / ceil(21/6))}} 99.75%
{{percent|NaN}} NaN%