Template:Cents/doc: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Ganaram inukshuk (talk | contribs)
do not overcomplicate
ArrowHead294 (talk | contribs)
mNo edit summary
Line 3: Line 3:
Use this template like this
Use this template like this


: <code><nowiki>{{cents|ratio|precision}}</nowiki></code>
<pre>{cents|ratio|precision}}</pre>


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


produces the following output
produces the following output
Line 13: Line 13:


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


gives:
gives:

Revision as of 16:46, 8 November 2024

Usage

Use this template like this

{cents|ratio|precision}}

Example

This input in the wiki source

{{cents|3/2|5}}

produces the following output

{{subst:#number_format: {{subst:#expr: 1200 * ln({{subst:#rmatch: 3/2|^(.*?)[Cc]?$|\1}}) / ln(2)}}|5|.|}}{{subst:#switch: {{subst:#rmatch: 3/2|^.*?([Cc]?)$|\1}}|c= ¢|C= ¢|#default=}}

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

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

gives:

{{subst:#number_format: {{subst:#expr: 1200 * ln({{subst:#rmatch: 3^12/2^19|^(.*?)[Cc]?$|\1}}) / ln(2)}}|5|.|}}{{subst:#switch: {{subst:#rmatch: 3^12/2^19|^.*?([Cc]?)$|\1}}|c= ¢|C= ¢|#default=}}

See also