Last modified: 2008-08-11 20:20:21 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T13156, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 11156 - Formatnum and expr gives erroneous calculation
Formatnum and expr gives erroneous calculation
Status: RESOLVED WORKSFORME
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-09-02 16:57 UTC by Joanjoc
Modified: 2008-08-11 20:20 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Joanjoc 2007-09-02 16:57:10 UTC
This error ocurrs in wikipedias using comma as a decimal separator according to the wiki's default locale, like in catalan wikipedia. 

Tthe formatnum magicword almost follows the wiki locale, but the parser function #expr: use the dot as a decimal separator. This differences results in erroneous calculus in some templates. There's a set of examples at; 

http://ca.wikipedia.org/wiki/Usuari:Joanjoc/formatnum
Comment 1 Jelte (WebBoy) 2008-08-11 20:20:21 UTC
You should use only English numbers without thousand separator (like 1000000.45) in #expr and formatnum without R.

To transform numbers from a local number ( like 1.000.000,45 ) to an English number without thousand separator, use {{formatnum: number |R}} (note the R):

{{formatnum: 1.000.000,45 |R}} => 1000000.45

Therefore, to multiply a local number with 10, and output a local number, you should use:

{{formatnum: {{#expr: {{formatnum: 5.199,75 | R }} * 10 }} }}

Output: 51.997,5

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links