Last modified: 2013-11-20 13:47:09 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 T58682, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 56682 - Avoid floating point errors when manipulating decimal values
Avoid floating point errors when manipulating decimal values
Status: VERIFIED FIXED
Product: MediaWiki extensions
Classification: Unclassified
WikidataRepo (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Wikidata bugs
quantityvalue
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-06 19:05 UTC by Daniel Kinzler
Modified: 2013-11-20 13:47 UTC (History)
4 users (show)

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


Attachments

Description Daniel Kinzler 2013-11-06 19:05:46 UTC
Floating point errors should be avoided when handling/manipulating QueryValue and DecimalValue objects. One situation where such errors frequently show is when adding an uncertainty margin to a base amount to comput the upper and lower bounds of a quantity.

The errors are introduced because DecimalMath, a class that implements basic arithmetical operation on DecimalValue objects, uses float numbers to perform the calculations.

To avoid this, we could use the bcmath library, if it is installed.

Also, smart rounding rules could be employed to reduce the ill effects of floating point errors.
Comment 1 Daniel Kinzler 2013-11-06 19:07:21 UTC
Example:

           "raw": "3+/-0.01\u00b0",
            "value": {
                "amount": "+3",
                "unit": "\u00b0",
                "upperBound": "+3.0099999999999997868371792719699442386627197265625",
                "lowerBound": "+2.9900000000000002131628207280300557613372802734375"
            },
            "type": "quantity"
Comment 2 Gerrit Notification Bot 2013-11-08 14:11:43 UTC
Change 94355 had a related patch set uploaded by Daniel Kinzler:
(bug 56682) DecimalMath now uses bcmath if available

https://gerrit.wikimedia.org/r/94355
Comment 3 Gerrit Notification Bot 2013-11-08 15:06:39 UTC
Change 94367 had a related patch set uploaded by Daniel Kinzler:
(bug #56682) Use DecimalMath for getUncertaintyMargin

https://gerrit.wikimedia.org/r/94367
Comment 4 Gerrit Notification Bot 2013-11-13 17:44:47 UTC
Change 94355 merged by jenkins-bot:
(bug 56682) DecimalMath now uses bcmath if available

https://gerrit.wikimedia.org/r/94355
Comment 5 Gerrit Notification Bot 2013-11-14 15:04:04 UTC
Change 94367 merged by jenkins-bot:
(bug #56682) Use DecimalMath for getUncertaintyMargin.

https://gerrit.wikimedia.org/r/94367
Comment 6 abraham.taherivand 2013-11-20 13:47:09 UTC
Verified in Wikidata demo time.

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


Navigation
Links