Template:Cents: Difference between revisions

Xenwolf (talk | contribs)
... commenting out is a bit complicated in templates - but now hopefully fixed
Xenwolf (talk | contribs)
ready to go
Line 1: Line 1:
<noinclude><!-- {{#number_format:{{#expr: 1200*ln({{{1|{{{ratio|1}}}}}})/ln(2)}}|{{{2|{{{precision|0}}}}}}|.|}} <ORIGINAL NOINCLUDE>
{{<includeonly>subst:</includeonly>#number_format:{{<includeonly>subst:</includeonly>#expr: 1200*ln({{{1|{{{ratio|1}}}}}})/ln(2)}}|{{{2|{{{precision|0}}}}}}|.|}}<noinclude>
 
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.


<big>It requires the MediaWiki [https://www.mediawiki.org/wiki/Extension:NumberFormat Extension:NumberFormat] being [[Special:Version|installed]].</big>
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 ==
Use this template like this
 
<nowiki>{{subst:cents|ratio|precision}}</nowiki>


[[Category:Templates]]
== Example ==
--></noinclude>{{#expr: 1200*ln({{{1|{{{ratio|1}}}}}})/ln(2) round {{{precision|{{{2|0}}}}}}}}<noinclude>
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.


<big>'''This is a temporary solution.'''</big>
this input in the wiki source
<nowiki>{{subst:cents|3|5}}</nowiki>


It doesn't care for dangling zeros, exactly following [http://php.net/manual/en/function.round.php PHP's round function].
produces the following output
1901.95500


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