我是靠谱客的博主 搞怪煎蛋,这篇文章主要介绍java中 大数取对数_Java BigDecimal的对数,现在分享给大家,希望可以做个参考。

小编典典

Java Number Cruncher:《 Java数值计算程序员指南》提供了使用牛顿方法的解决方案。这本书的源代码在这里。以下内容摘自第12.5章大十进制函数(p330&p331):

/**

* Compute the natural logarithm of x to a given scale, x > 0.

*/

public static BigDecimal ln(BigDecimal x, int scale)

{

// Check that x > 0.

if (x.signum() <= 0) {

throw new IllegalArgumentException("x <= 0");

}

// The number of digits to the left of the decimal point.

int magnitude = x.toString().length() - x.scale() - 1;

if (magnitude < 3) {

return lnNewton(x, scale);

}

// Compute magnitude*ln(x^(1/magnitude)).

else {

// x^(1/magnitude)

BigDecimal root = intRoot(x, magnitude, scale);

// ln(x^(1/magnitude))

BigDecimal lnRoot = lnNewton(root, scale);

// magnitud

最后

以上就是搞怪煎蛋最近收集整理的关于java中 大数取对数_Java BigDecimal的对数的全部内容,更多相关java中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(135)

评论列表共有 0 条评论

立即
投稿
返回
顶部