Java BigDecimal三角法 [英] Java BigDecimal trigonometric methods

查看:131
本文介绍了Java BigDecimal三角法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个数学解析器,它能够像'5 + b * sqrt(c ^ 2)'一样评估字符串。我正在使用ANTLR进行解析并取得良好进展。现在我跌破了Java类 BigDecimal 并且想:嘿,为什么不在这里考虑精度。

I am developing a mathematical parser which is able to evaluate String like '5+b*sqrt(c^2)'. I am using ANTLR for the parsing and make good progress. Now I fell over the Java class BigDecimal and thought: hey, why not thinking about precision here.

我的问题是Java API不为 BigDecimal 提供三角形方法,如 java.lang.Math 。你知道是否有像Apache Commons这样的好的数学库可以解决这个问题吗?

My problem is that the Java API does not provide trigonometric methods for BigDecimals like java.lang.Math. Do you know if there are any good math libraries like Apache Commons out there that deal with this problem?

其他问题是如何实现电源方法以便我可以用 BigDecimal 计算4.9 ^ 1.4。这可能吗?

The other questions is how to realize the power method so that I can calculate 4.9 ^ 1.4 with BigDecimals. Is this possible?

关于数值计算的书籍请求也很受欢迎。

A book request about numerical computing is also appreciated.

推荐答案

ApFloat 是一个包含三角函数和非整数幂的任意精度近似的库都;但是,它使用自己的内部表示,而不是 BigDecimal BigInteger 。我之前没有使用它,所以我不能保证其正确性或性能特征,但api似乎相当完整。

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.

这篇关于Java BigDecimal三角法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆