Page MenuHomePhabricator

"Round" operator broken
Closed, DeclinedPublic

Description

Author: zocky

Description:
{{#expr: 45 round 2}} returns "45" instead of "45.00" which would be the
expected behaviour and useful for aligning numbers.


Version: unspecified
Severity: normal

Details

Reference
bz6529

Event Timeline

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

omniplex wrote:

Not really "broken", all expression results COULD
go through the same normalization at the end, and
that would strip trailing or leading zeros, force
scientific format below E-5 / above 1E12, etc.

Oddity, "round" does return -0 in some cases, so
if you'd want normalized results (the opposite of
your bug report) you have to add 0 to get rid of
the bogus minus sign in -0.

I didn't look at the new "formatnum" magic word,
does it help?

drspui wrote:

If the number of decimal places is given, it should round to that many places to
make it clear that the number is given with that precision. This is broken behavior.

Change 405870 had a related patch set uploaded (by Rammanojpotla; owner: Rammanoj):
[mediawiki/extensions/ParserFunctions@master] Fix improper working of "round" operator

https://gerrit.wikimedia.org/r/405870

Change 405870 abandoned by Rammanojpotla:
Fix working of "round" operator

https://gerrit.wikimedia.org/r/405870

Change 406823 had a related patch set uploaded (by Rammanojpotla; owner: Rammanoj):
[mediawiki/extensions/ParserFunctions@master] Modify rounding technique

https://gerrit.wikimedia.org/r/406823

thiemowmde subscribed.

See the discussions on the linked Gerrit patches for the reason why I'm declining this ticket after 11 years with nobody else having an issue with the way the round feature works.

Change 406823 abandoned by Rammanojpotla:
Modify rounding technique

https://gerrit.wikimedia.org/r/406823