Template:Format price
Revision as of 16:39, 28 December 2016 by Randombell (talk | contribs) (Created page with "{{#iferror:{{ #ifexpr:({{{1}}} >= 1E+27) | {{formatnum:{{Format price/digits|{{#expr:{{{1}}} / 1E+27}}}}}} octillion}}{{ #ifexpr:(({{{1}}} >= 1E+24) and ({{{1}}} < 1E+27)...")
This template displays numbers typically representing prices in a pleasant way, ideally suited for articles. Numbers one thousand or greater 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, which does not always happen with the {{formatnum:}} magic word.
Contents
Usage
{{Format price|value|digits}}
Where:
- value: the value that will be formatted and displayed (required).
- digits: sets the digit in which a value lower than one thousand 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. Despite its name, this template only handles the number-formatting, not any unit symbols – consider {{currency}} for that separate feature.
Examples
- 13px
{{Format price|1.2}}
= 1.20 - 13px
{{Format price|456.789}}
= 456.79 - 13px
{{Format price|456.789|1}}
= 456.80 - 13px
{{Format price|456.789|0}}
= 457 - 13px
{{Format price|456.789|-2}}
= 500 - 13px $
{{Format price|1234}}
= $1.23 thousand - 13px $
{{Format price|12345}}
= $12.3 thousand - 13px $
{{Format price|123456}}
= $123 thousand - 13px $
{{Format price|1000000}}
= $1 million - 13px ¥
{{Format price|98765432109876}}
= ¥98.8 trillion - 13px
{{Format price|7.86178E+25}}
atoms = 78.6 septillion atoms
Wrong
- 13px
{{Format price}}
= NaN (empty parameter) - 13px
{{Format price||0}}
= NaN (empty first parameter) - 13px
{{Format price|-100}}
= NaN (negative values are invalid) - 13px
{{Format price|xyz|A}}
= NaN (only numeric values are allowed) - 13px
{{Format price|1E+309}}
= NaN (overflow)
See also
- {{Inflation}}
- {{Inflation-fn}}
<templatestyles src="Module:Message box/fmbox.css"></templatestyles>
The above documentation is transcluded from Template:Format price/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |