Template:Cents/doc: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{dochead}}
{{dochead}}{{substitute|always}}
This template calculates the cent value of its first argument (defaults to 1). An optional second argument controls the precision, it defaults to 0 decimal places.
 
=== Usage ===
=== Usage ===
Use this template like this
Use this template like this


<pre>{cents|ratio|precision}}</pre>
<pre>{{subst: cents|ratio|prec}}</pre>


=== Example ===
=== Example ===
This input in the wiki source
This input in the wiki source
<pre>{{cents|3/2|5}}</pre>
<pre>{{subst: cents|3/2|5}}</pre>


produces the following output
produces the following output
: {{{{ROOTPAGENAME}}|3/2|5}}
: 701.95500


Intervals can even be typed as evaluable mathematical expressions. For example:
Intervals can even be typed as evaluable mathematical expressions. For example:
<pre>{{cents|3^12/2^19|5}}</pre>
 
<pre>{{subst: cents|3^12/2^19|5}}</pre>


gives:
gives:
: {{{{ROOTPAGENAME}}|3^12/2^19|5}}
 
: 23.46001
 
Add in a lowercase C to the end of the expression to add {{tlx|c}}:
 
<pre>{{subst: cents|5/4c|2}}</pre>
 
gives:
 
: 386.31{{c}}
 
Add in an uppercase C to add {{tlx|cent}}:
 
<pre>{{subst: cents|5/4C|2}}</pre>
 
gives:
 
: 386.31{{cent}}


=== See also ===
=== See also ===
* [[Template:Cent]] &ndash; A template to insert the cent symbol
* [[Template:Cent]], [[Template:C]] – templates to insert the cent symbol, with and without (respectively) a link to [[cent|the article about cents]].