New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
precision over 1000 causing DecimalError for trig functions on a BigNumber #1385
Comments
According to the docs of Decimal.js:
Looking in the code of decimal.js though, I see that https://github.com/MikeMcl/decimal.js/blob/master/decimal.js#L33 To resolve this I guess we could fallback on calculating pi on the fly with higher precision. |
Note that calculations without pi can be done with higher precision without any issue: math.config({ precision: 10000 })
math.bignumber(1).div(3).toString() // 0.3333333... many digits... |
Why then 1/3 gives me that error when precision is over 1000?
…On Thu, 17 Jan 2019, 19:38 Jos de Jong ***@***.*** wrote:
Note that calculations without pi can be done with higher precision
without any issue:
math.config({ precision: 10000 })
math.bignumber(1).div(3).toString() // 0.3333333... many digits...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1385 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABHXrNxjsb9cRPNyN7gLJFbISdSSrTomks5vENFCgaJpZM4aERuQ>
.
|
Could you share an example of code that throws that error? |
Yes sure: Actually, seems problem is not with eval, but with |
That's interesting. Looks indeed that On a side note: I think working with a precision over 1000 digits is theoretical? Or is there a real daily use case for this? |
We have a number of users of numerics.info working with ultra precise
calculations. Some of them use 4000 digits. Especially since library
essentially supports this, why to impose unnecessary limitations?
…On Sun, 20 Jan 2019, 19:21 Jos de Jong ***@***.*** wrote:
That's interesting. Looks indeed that math.format triggers the limit on
1025 that Decimal.js has. Would be great if anyone can look into the cause
and possible workaround for this.
On a side note: I think working with a precision over 1000 digits is
theoretical? Or is there a real daily use case for this?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1385 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABHXrL_rNb4U_l45TrjH7T9RgQjUrOv3ks5vFMHCgaJpZM4aERuQ>
.
|
I'm taking a look into it right now. |
It fails because the const exp = value.abs().logarithm()
if (exp.gte(lowerExp) && exp.lt(upperExp)) {
// normal number notation
} else {
// exponential notation
} But const exp = value.e
if (exp >= lowerExp && exp < upperExp) {
// normal number notation
} else {
// exponential notation
} I would presume that normally, #1387 is a fix that works so long as |
@ericman314 Thanks for a solution and detailed explanation. |
@husayt is the fix of Eric enough to solve your issue? It means that precision above 1000 digits works for arithmetic operations like multiplication and addition, but still not for trigonometric operations involving |
Yes this issue with formatting is thankfully resolved, and yes Pi issue is
still on the table and hopefully will find its solution soon. They are
related, but separate issues. I noticed in discussion you had a good idea
about resolving that too, so looking forward to it .
Thanks
…On Mon, 21 Jan 2019, 20:22 Jos de Jong ***@***.*** wrote:
@husayt <https://github.com/husayt> is the fix of Eric enough to solve
your issue? It means that precision above 1000 digits works for arithmetic
operations like multiplication and addition, but still not for
trigonometric operations involving pi.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1385 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABHXrJPEG8u0eNQ2dGP9SuAJdOv_CX8iks5vFiFzgaJpZM4aERuQ>
.
|
👍 then I will keep this issue open as a reminder |
The issue with |
When I try big precisions over 1000 this is the error I get:
If there is a limit to precision, would be nice to document this, otherwise this is an issue
The text was updated successfully, but these errors were encountered: