Java BigDecimal trigonometric methods
ApFloat is a library which contains arbitrary-precision approximations of trigometric functions and non-integer powers both; however, it uses its own internal representations, rather than BigDecimal
and BigInteger
. I haven't used it before, so I can't vouch for its correctness or performance characteristics, but the api seems fairly complete.
BigDecimal
does not provide these methods because BigDecimal
models a rational number. Trigonometric functions, square roots and powers to non-integers (which I guess includes square roots) all generate irrational numbers.
These can be approximated with an arbitrary-precision number but the exact value can't be stored in a BigDecimal
. It's not really what they're for. If you're approximating something anyway, you may as well just use a double
.
The big-math library provides all the standard advanced mathematical functions (pow, sqrt, log, sin, ...) for BigDecimal.
https://github.com/eobermuhlner/big-math