Template:Cents/doc: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(12 intermediate revisions by 3 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


: <code>{{((}}cents{{pipe}}ratio{{pipe}}precision{{))}}</code>
<pre>{{subst: cents|ratio|prec}}</pre>


=== Example ===
=== Example ===
This input in the wiki source
This input in the wiki source
: <code>{{((}}cents{{pipe}}3/2{{pipe}}5{{))}}</code>
<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:
: <code>{{((}}cents{{pipe}}3^12/2^19{{pipe}}5{{))}}</code>
 
<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]].

Latest revision as of 16:07, 6 August 2025

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