SandBox: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Xenwolf (talk | contribs)
#expr: added source
Xenwolf (talk | contribs)
made the actual problem more obvious
Line 17: Line 17:
but for formatting rounded results, it would be good to use [https://www.mediawiki.org/wiki/Extension:NumberFormat Extension:NumberFormat - MediaWiki]
but for formatting rounded results, it would be good to use [https://www.mediawiki.org/wiki/Extension:NumberFormat Extension:NumberFormat - MediaWiki]


... which is currently not available:
... which is currently not available (it's displaying just the code I typed):


{{#number_format:12 345 678,055555|_|.||,}}
{{#number_format:12 345 678,055555|_|.||,}}
'''The Problem''' that can be solved by <code><nowiki>{{#number_format: [...]</nowiki></code> is that
<code><nowiki> {{#expr: (ln (3/2) / ln 2 * 1200) round 5}}</nowiki></code> gives us <tt>{{#expr: (ln (3/2) / ln 2 * 1200) round 5}}</tt> instead of <tt>701.95500</tt> if 5 decimals are requested, as indicated by the <tt>5</tt> after <tt>round</tt>.

Revision as of 17:48, 24 October 2018


This is the sandbox. To experiment with editing, click on the [Edit] tab.

#expr

Help:Extension:ParserFunctions - MediaWiki #expr

We can build a cent function:

* {{#expr: ln (9/8) / ln 2 * 1200}}
* {{#expr: ln (3/2) / ln 2 * 1200}}
* {{#expr: ln (5/4) / ln 2 * 1200}}
  • 203.91000173077
  • 701.95500086539
  • 386.31371386483

but for formatting rounded results, it would be good to use Extension:NumberFormat - MediaWiki

... which is currently not available (it's displaying just the code I typed):

12345678.055555

The Problem that can be solved by {{#number_format: [...] is that {{#expr: (ln (3/2) / ln 2 * 1200) round 5}} gives us 701.955 instead of 701.95500 if 5 decimals are requested, as indicated by the 5 after round.