Comments (2)
Bug confirmed.
I will probably go for the
if(mathContext.getPrecision()==0) throw new UnsupportedOperationException("Unlimited MathContext is not supported");
solution
from big-math.
Fix BigDecimalMath
functions with MathContext.UNLIMITED
The behaviour of the BigDecimalMath
functions when being used with the MathContext.UNLIMITED
was badly defined.
In many cases the calculation was done with a low precision like 10.
The functions that calculate the result with an algorithm using well defined and obvious operations
may throw the same ArithmeticException
as the underlying BigDecimal
operations
if the specified MathContext
has a precision of 0 (for example MathContext.UNLIMITED
):
BigDecimalMath.reciprocal(BigDecimal)
BigDecimalMath.bernoulli(int, MathContext)
BigDecimalMath.factorial(BigDecimal, MathContext)
with integer argumentBigDecimalMath.gamma(BigDecimal, MathContext)
with integer argumentBigDecimalMath.pow(BigDecimal, long, MathContext)
All other functions that use approximations to calculate the result will throw a UnsupportedOperationException
if the specified MathContext
has a precision of 0 (for example MathContext.UNLIMITED
):
BigDecimalMath.factorial(BigDecimal, MathContext)
with non-integer argumentBigDecimalMath.gamma(BigDecimal, MathContext)
with non-integer argumentBigDecimalMath.pow(BigDecimal, BigDecimal, MathContext)
BigDecimalMath.sqrt(BigDecimal, MathContext)
BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)
BigDecimalMath.log(BigDecimal, MathContext)
BigDecimalMath.log2(BigDecimal, MathContext)
BigDecimalMath.log10(BigDecimal, MathContext)
BigDecimalMath.pi(MathContext)
BigDecimalMath.e(MathContext)
BigDecimalMath.exp(BigDecimal, MathContext)
BigDecimalMath.sin(BigDecimal, MathContext)
BigDecimalMath.asin(BigDecimal, MathContext)
BigDecimalMath.cos(BigDecimal, MathContext)
BigDecimalMath.acos(BigDecimal, MathContext)
BigDecimalMath.tan(BigDecimal, MathContext)
BigDecimalMath.atan(BigDecimal, MathContext)
BigDecimalMath.atan2(BigDecimal, BigDecimal MathContext)
BigDecimalMath.cot(BigDecimal, MathContext)
BigDecimalMath.acot(BigDecimal, MathContext)
BigDecimalMath.sinh(BigDecimal, MathContext)
BigDecimalMath.cosh(BigDecimal, MathContext)
BigDecimalMath.tanh(BigDecimal, MathContext)
BigDecimalMath.coth(BigDecimal, MathContext)
BigDecimalMath.asinh(BigDecimal, MathContext)
BigDecimalMath.acosh(BigDecimal, MathContext)
BigDecimalMath.atanh(BigDecimal, MathContext)
BigDecimalMath.acoth(BigDecimal, MathContext)
from big-math.
Related Issues (20)
- Prepare release 2.2.0
- Nullpointer exception in SeriesCalculator 121 line HOT 4
- Prepare release 2.2.1
- Support temporary local MathContext in DefaultBigDecimalMath
- Prepare release 2.3.0
- root(x, n) with large n is very slow
- Prepare release 2.3.1 HOT 2
- sqrt hangs HOT 1
- sqrt rounding HOT 2
- BigRational toFloat() can fail in a slightly unexpected way HOT 4
- `BigRational.toIntegerRationalString()` with small negative numbers
- Issue with larger scales? HOT 3
- Questions about the big-math library: Capabilities and Future. HOT 12
- Something the matter with the 2.3.1 release? HOT 1
- Prepare release 2.3.2
- Question about big-math .jar file. HOT 1
- Performance issue in BigDecimalMath.pow() HOT 1
- BigComplexMath.sqrt fails on non-positive real numbers HOT 2
- Use BigDecimal.compareTo() insted of BigDecimal.equals()
- Pow throws Overflow in special case
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from big-math.