Math.exp 函数在 Java 中的限制

Limitation of Math.exp Function in Java

我正在实现一种算法,其中我需要高小数精度,所以我使用 BigDecimal 但 Math.exp 只接受双精度参数。

值在 运行 时生成并作为参数传递给 Math.exp 即

BigDecimal mathEx = new BigDecimal( Math.exp(xMulXPoint5.doubleValue()));
Where xMulXPoint5 = -347222407183165.419208175

mathEx 结果值太小以至于结果显示零而不是实际的小值。

任何人都可以建议任何其他方法来解决这个问题。

您可以使用 BigDecimal 定义自己的 exp 函数,然后使用它,而不是 Math.exp

我找到了这个。也许这个话题会有所帮助

BigDecimal Euler's number calculation to emulate Math.exp(double a)

希望对您有所帮助