Template:Cents/doc: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
No edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
Line 2: Line 2:
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.
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.


This template should always be combined with the <code>subst:</code> keyword (i.e. {{w|WP:SUBST|substituted}}). The substitution is already carried out for the page preview. At save, the cent value is being placed into the wiki source.
This template should always be [[mw:H:SUBST|substituted]] (combined with the <code>subst:</code> keyword). The substitution is already carried out for the page preview. At save, the cent value is being placed into the wiki source.


=== Usage ===
=== Usage ===
Line 25: Line 25:


=== See also ===
=== See also ===
* [[Template: Cent]] – a template to insert the cent symbol
* [[Template:Cent]], [[Template:C]] – templates to insert the cent symbol

Revision as of 15:13, 14 March 2025

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.

This template should always be substituted (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

Use this template like this

{{subst: cents|ratio|precision}}

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

See also