Comments (6)
Bug confirmed.
The result of pow(1.5, 1e10) is outside the range that BigDecimal supports for the scale (which only allows int values).
This should throw an exception.
from big-math.
Fix is pushed and will be in the next release.
from big-math.
Result of 1.5^(1e10) is +- 3.6e1760912590, exponent 1760912590 can be represented as integer. Wouldn't it be an option to use a long for the pow's y parameter? Just a remark, the current solution is good enough for my needs.
from big-math.
You are right, the result has the exponent still in the integer range and although the y value is outside of integer range the calculation should still work.
I have not yet decided whether I should go with your proposed solution using longValueExact() or whether I should make it work with all BigDecimal y values that have no fractional part.
from big-math.
I decided to go the full way.
pow(BigDecimal, int)
is changed to pow(BigDecimal, long)
that should handle your case.
Added BigDecimal powInteger(BigDecimal x, BigDecimal integerY, MathContext mathContext)
that can calculate the pow() with integral values beyond longValueExact()
.
This implementation is slower than pow(BigDecimal, long)
so it is only used if necessary.
from big-math.
Released in 2.0.0
from big-math.
Related Issues (20)
- 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
- doubleValue performance
- BigComplexMath#sqrt fails when x is a negative real number
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.