Changes
no edit summary
{{Documentation subpage}}
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 <tt><nowiki>{{formatnum:}}</nowiki></tt> [[Help:Magic words|magic word]].
=== Usage ===
{{tlx|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 {{tl|currency}} for that separate feature.
==== Examples ====
* {{aye}} {{tlx|Format price|1.2}} = {{Format price|1.2}}
* {{aye}} {{tlx|Format price|456.789}} = {{Format price|456.789}}
* {{aye}} {{tlx|Format price|456.789|1}} = {{Format price|456.789|1}}
* {{aye}} {{tlx|Format price|456.789|0}} = {{Format price|456.789|0}}
* {{aye}} {{tlx|Format price|456.789|-2}} = {{Format price|456.789|-2}}
* {{aye}} <tt>'''$'''{{tlx|Format price|1234}}</tt> = ${{Format price|1234}}
* {{aye}} <tt>'''$'''{{tlx|Format price|12345}}</tt> = ${{Format price|12345}}
* {{aye}} <tt>'''$'''{{tlx|Format price|123456}}</tt> = ${{Format price|123456}}
* {{aye}} <tt>'''$'''{{tlx|Format price|1000000}}</tt> = ${{Format price|1000000}}
* {{aye}} <tt>'''¥'''{{tlx|Format price|98765432109876}}</tt> = ¥{{Format price|98765432109876}}
* {{aye}} <tt>{{tlx|Format price|7.86178E+25}} atoms</tt> = {{Format price|7.86E+25}} atoms
=====Wrong=====
* {{nay}} {{tlx|Format price}} = {{Format price}} (empty parameter)
* {{nay}} {{tlx|Format price|{{!}}0}} = {{Format price||0}} (empty first parameter)
* {{nay}} {{tlx|Format price|-100}} = {{Format price|-100}} (negative values are invalid)
* {{nay}} {{tlx|Format price|xyz|A}} = {{Format price|xyz|A}} (only numeric values are allowed)
* {{nay}} {{tlx|Format price|1E+309}} = {{Format price|1E+309}} (overflow)
=== See also ===
* {{tl|Inflation}}
* {{tl|Inflation/fn}}
<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
{{DEFAULTSORT:Format Price}}
[[Category:Currency conversion templates]]
[[Category:Economics formatting and function templates]]
[[Category:Finance templates]]
}}</includeonly>
<templatedata>
{
"params": {
"1": {
"label": "value",
"description": "the value that will be formatted and displayed",
"example": "1,000",
"type": "number",
"required": true
},
"2": {
"label": "digits",
"description": "sets the digit in which a value lower than one thousand must be rounded, defaulting to \"2\" (cents) if unspecified",
"type": "number",
"suggested": true
}
},
"paramOrder": [
"1",
"2"
]
}
</templatedata>
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 <tt><nowiki>{{formatnum:}}</nowiki></tt> [[Help:Magic words|magic word]].
=== Usage ===
{{tlx|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 {{tl|currency}} for that separate feature.
==== Examples ====
* {{aye}} {{tlx|Format price|1.2}} = {{Format price|1.2}}
* {{aye}} {{tlx|Format price|456.789}} = {{Format price|456.789}}
* {{aye}} {{tlx|Format price|456.789|1}} = {{Format price|456.789|1}}
* {{aye}} {{tlx|Format price|456.789|0}} = {{Format price|456.789|0}}
* {{aye}} {{tlx|Format price|456.789|-2}} = {{Format price|456.789|-2}}
* {{aye}} <tt>'''$'''{{tlx|Format price|1234}}</tt> = ${{Format price|1234}}
* {{aye}} <tt>'''$'''{{tlx|Format price|12345}}</tt> = ${{Format price|12345}}
* {{aye}} <tt>'''$'''{{tlx|Format price|123456}}</tt> = ${{Format price|123456}}
* {{aye}} <tt>'''$'''{{tlx|Format price|1000000}}</tt> = ${{Format price|1000000}}
* {{aye}} <tt>'''¥'''{{tlx|Format price|98765432109876}}</tt> = ¥{{Format price|98765432109876}}
* {{aye}} <tt>{{tlx|Format price|7.86178E+25}} atoms</tt> = {{Format price|7.86E+25}} atoms
=====Wrong=====
* {{nay}} {{tlx|Format price}} = {{Format price}} (empty parameter)
* {{nay}} {{tlx|Format price|{{!}}0}} = {{Format price||0}} (empty first parameter)
* {{nay}} {{tlx|Format price|-100}} = {{Format price|-100}} (negative values are invalid)
* {{nay}} {{tlx|Format price|xyz|A}} = {{Format price|xyz|A}} (only numeric values are allowed)
* {{nay}} {{tlx|Format price|1E+309}} = {{Format price|1E+309}} (overflow)
=== See also ===
* {{tl|Inflation}}
* {{tl|Inflation/fn}}
<includeonly>{{sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
{{DEFAULTSORT:Format Price}}
[[Category:Currency conversion templates]]
[[Category:Economics formatting and function templates]]
[[Category:Finance templates]]
}}</includeonly>
<templatedata>
{
"params": {
"1": {
"label": "value",
"description": "the value that will be formatted and displayed",
"example": "1,000",
"type": "number",
"required": true
},
"2": {
"label": "digits",
"description": "sets the digit in which a value lower than one thousand must be rounded, defaulting to \"2\" (cents) if unspecified",
"type": "number",
"suggested": true
}
},
"paramOrder": [
"1",
"2"
]
}
</templatedata>