You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would happen when toLessThanHalfPi() turns x to 'zero' in P.sin/P.cos (e.g. fractional part of the remainder after subtracting pi gives a number with e<minE) before calling taylorSeries() with that x.
Reproduction steps:
pi = Decimal.set({precision:30}).acos(-1);
s = Decimal.set({minE:-25}).sin(pi); //<-- calling cos() here would loop too.
There are not enough guards (or positioned incorrectly) in P.sin() or P.cos().
taylorSeries() should also check on its own to guard against infinite loops.
I am writing a simple calculator and was hoping that at least trivial cases like sin(pi) cos(pi) would return something less hairy like 5.2322..e-50 and hence the temporary changing of minE (misuse?)
The text was updated successfully, but these errors were encountered:
Yes, it's a bug, which only appears when an approximation of Pi is passed to sin or cos, and minE is low enough for the return value from toLessThanHalfPi to be zero. The sin and cos methods need to be amended to check for a zero result from toLessThanHalfPi.
Thanks for the report.
This bug doesn't appear in the current unpublished version of this library, which can be found here, in my last post. Therefore, this bug will be fixed when that version is finally published.
This would happen when toLessThanHalfPi() turns x to 'zero' in P.sin/P.cos (e.g. fractional part of the remainder after subtracting pi gives a number with e<minE) before calling taylorSeries() with that x.
Reproduction steps:
pi = Decimal.set({precision:30}).acos(-1);
s = Decimal.set({minE:-25}).sin(pi); //<-- calling cos() here would loop too.
I am writing a simple calculator and was hoping that at least trivial cases like sin(pi) cos(pi) would return something less hairy like 5.2322..e-50 and hence the temporary changing of minE (misuse?)
The text was updated successfully, but these errors were encountered: