Template:Formatprice

From Wikipedia, the free encyclopedia

This template employs intricate features of template syntax.
You are encouraged to familiarise yourself with its setup and parser functions before editing the template. If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages.
Remember that you can conduct experiments, and should test all improvements, in either the general Template sandbox or your user space before changing anything here.
[edit] Template documentation

This template display numbers typically representing prices in a pleasant way, ideally suited for articles. Numbers above one million are reduced down and rounded to a total of three digits followed by a multiplier text, and smaller numbers received separators and exactly two digits to represent cents, what doesn't always happen with the {{formatnum:}} magic word.

[edit] Usage

{{Formatprice|value|digits}}

Where:

  • value – the value that will be formatted and displayed (required).
  • digits – sets the digit in which a value lower than one million must be rounded, defaulting to "2" (cents) if unspecified.

Providing non-numeric parameters, failing to provide any parameter, or providing a negative value parameter, result all in a link to the NaN article.

[edit] Examples

  • {{Formatprice|1.2}} = 1.20
  • {{Formatprice|23456.789}} = 23,456.79
  • {{Formatprice|23456.789|1}} = 23,456.80
  • {{Formatprice|23456.789|0}} = 23,457
  • {{Formatprice|23456.789|-2}} = 23,500
  • ${{Formatprice|1234567}} = $1.23 million
  • ${{Formatprice|12345678}} = $12.3 million
  • ${{Formatprice|123456789}} = $123 million
  • ${{Formatprice|1000000000}} dollars = $1 billion dollars
  • ¥{{Formatprice|98765432109876}} yens = ¥98.8 trillion yens
  • {{Formatprice|7.86178E+25}} atoms = 78.6 septillion atoms
  • {{Formatprice}} = NaN
  • {{Formatprice||0}} = NaN
  • {{Formatprice|-100}} = NaN
  • {{Formatprice|xyz|A}} = NaN

[edit] See also