JDK 9 RFR of JDK-4851777 Add BigDecimal sqrt method

Brian Burkhalter brian.burkhalter at oracle.com
Fri May 20 20:39:38 UTC 2016


Hi Joe,

I’ve a few comments / questions, mostly picayune.

On May 19, 2016, at 11:43 PM, joe darcy <joe.darcy at oracle.com> wrote:

> Please review the addition of BigDecimal.sqrt:
> 
>     JDK-4851777 Add BigDecimal sqrt method
> 
>    http://cr.openjdk.java.net/~darcy/4851777.5/

2023      * <li> The square root of a number numerically equal to {@code
Extraneous space after “<li>”.
2057              * The main steps of the algorithm below are as follow, first
“follow” -> “follows”
2104             // root, it is helpful to instead normalize this as so
I think the “as” is unneeded.
2110             int scale = stripped.scale() - stripped.precision() + 1;
The “+ 1” here is I suppose because in the referenced ACM paper they work with a normalized fraction “f” in the range [0.1,1.0) whereas here unscaledValue is a BigInteger. Then the analog of “f” in the BigDecimal case is the variable “working.”
2226      * the computed result for the chosen rounding mode .
Extraneous space before period.

In terms of additional testing, did you contemplate comparing the consistency of the results versus BigInteger.sqrt()? Obviously one would not be looking for equality in most cases.

All in all I think this looks good insofar as my reading can tell.

Reviewed +1.

Thanks,

Brian


More information about the core-libs-dev mailing list