Template:Cents: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Fredg999 (talk | contribs)
m Added See also section (to avoid confusion with a similar template)
ArrowHead294 (talk | contribs)
No edit summary
Line 5: Line 5:
It must always be combined with the ''subst:'' keyword. The substitution is already carried out for the page preview. At save, the cent value is being placed into the wiki source.
It must always be combined with the ''subst:'' keyword. The substitution is already carried out for the page preview. At save, the cent value is being placed into the wiki source.


== Usage ==
== Documentation ==
Use this template like this
{{/doc}}
 
<nowiki>{{subst:cents|ratio|precision}}</nowiki>
 
== Example ==
 
this input in the wiki source
<nowiki>{{subst:cents|3|5}}</nowiki>
 
produces the following output
1901.95500
 
== See also ==
* [[Template:Cent]] — a template to insert the cent symbol


[[Category:Substituted templates]]
[[Category:Substituted templates]]
</noinclude>
</noinclude>

Revision as of 05:41, 20 May 2024

0

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.

It must always be combined with the subst: keyword. The substitution is already carried out for the page preview. At save, the cent value is being placed into the wiki source.

Documentation

This template should always be substituted (i.e. use {{subst:Cents}}).

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

Use this template like this

{{subst: cents|ratio|prec}}

Example

This input in the wiki source

{{subst: cents|3/2|5}}

produces the following output

701.95500

Intervals can even be typed as evaluable mathematical expressions. For example:

{{subst: cents|3^12/2^19|5}}

gives:

23.46001

Add in a lowercase C to the end of the expression to add {{c}}:

{{subst: cents|5/4c|2}}

gives:

386.31 ¢

Add in an uppercase C to add {{cent}}:

{{subst: cents|5/4C|2}}

gives:

386.31 ¢

See also