[9] RFR of 8032027: Add BigInteger square root methods

Brian Burkhalter brian.burkhalter at oracle.com
Fri Oct 2 20:41:41 UTC 2015


Please review at your convenience.

Issue:	https://bugs.openjdk.java.net/browse/JDK-8032027
Patch:	http://cr.openjdk.java.net/~bpb/8032027/webrev.00/

Summary: Add sqrt() and sqrtAndRemainder() methods. The square root calculated is the integer square root ’s’ such that for a given integer ’n’ the value of ’s’ is the largest integer such that s*s <= n. In other words it is the floor of the mathematical square root of the value ’n' taken as a mathematical real number.

The method of calculation is Newton iteration starting from a value larger than the square root which ensures that the convergence is monotonically decreasing to the result. An effort is made to make the implementation efficient in particular with respect to the amount of memory used. Any suggestions as to the improvement of the approach concerning memory use or any other aspect of the algorithm would be appreciated, as would be suggestions regarding the test.

Thanks,

Brian


More information about the core-libs-dev mailing list