Page MenuHomePhabricator

Formatnum and expr gives erroneous calculation
Closed, DeclinedPublic

Description

Author: joanjoc

Description:
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


Version: unspecified
Severity: normal

Details

Reference
bz11156
TitleReferenceAuthorSource BranchDest Branch
maintain-kubeusers: bump to 0.0.122-20240221143623-84a40909repos/cloud/toolforge/toolforge-deploy!203project_1317_bot_df3177307bed93c3f34e421e26c86e38bump_maintain-kubeusersmain
user: fix bad permission for skel-copied filesrepos/cloud/toolforge/maintain-kubeusers!14dcarofix_permissionsmain
maintain-kubeusers: bump to 0.0.121-20240221131329-d6f9cd11repos/cloud/toolforge/toolforge-deploy!201project_1317_bot_df3177307bed93c3f34e421e26c86e38bump_maintain-kubeusersmain
user: copy stuff from /etc/skel if there's anythingrepos/cloud/toolforge/maintain-kubeusers!13dcarocopy_skelmain
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:47 PM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz11156.
bzimport added a subscriber: Unknown Object (MLST).

webboy wrote:

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