public static BigDecimal sqrt(BigDecimal A, final int SCALE) { BigDecimal x0 = new BigDecimal("0"); BigDecimal x1 = new BigDecimal(Math.sqrt(A.doublevalue())); while (!x0.equals(x1)) { x0 = x1; x1 = A.divide(x0, SCALE, ROUND_HALF_UP); x1 = x1.add(x0); x1 = x1.divide(TWO, SCALE, ROUND_HALF_UP); } return x1;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)