-
Notifications
You must be signed in to change notification settings - Fork 87
plus() number type has more than 15 significant digits: 0.00005192067222222222 #177
Comments
We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/108609786. |
Seems like BigNumber does not allow by default more than 15 digits (as mentioned in the API doc):
Not sure, but I think the problem lies in this line: |
We might want to wrap the BigNumber and configure it to have only 15 significant digits. If we want to keep the benefits of BigNumber we might want to keep all the digits in the DB and return only 15 to clients. Another approach would be to force them to use BigNumber? Another approach would be to check if the number is BigNumber or default JS type number and based on that construct a new BNumber or just reuse the existing one. WDYT? |
It seems we are hitting a restriction of BigNumber - it supports only 15 significant digits to keep precision. However there are numbers that have 16 or more digits in JS. Plain ints for example have 16:
This github issue mentions that this is done on purpose and suggests two solutions:
|
Disabling errors allowed me to get the report from Abacus. |
If I understand the BigNumber doc correctly, it is correct that Javascript supports 16 significant digits but some of these numbers will cause precision errors in floating point calculations and that's the reason why BigNumber introduced that limitation to 15 significant digits. Like you said the recommendation from BigNumber is to either turn off error messages or convert numbers to strings first. I'd rather just turn off the error message as that's less disruptive and passing strings doesn't make BigNumber support more than 15 digits either anyway. So I'd suggest to call I'm not sure that we need to do that BigNumber.config in the tests as the numbers these tests will be seeing shouldn't have more than 15 significant digits (as they'll have been produced by computations over BigNumbers in the first place). Makes sense? |
While trying to get the report for the current month I noticed this error is returned:
plus() number type has more than 15 significant digits: 0.00005192067222222222
The logs of the report app:
The text was updated successfully, but these errors were encountered: