As discussed during the code review of JDK-8233452, it should be possible to refine the loop termination conditions of the Newton iteration used to implement BigDecimal.sqrt. In particular, for the directed rounding conditions, it should be possible to knowingly keep the approximate solution on one side of the root or the other, avoiding the need for a fix-up check at the end. G. W. Stewart's "Afternotes on Numerical Analysis" has a discussion on the convergence of the square root iteration. Different alterations might be possible for the round-to-nearest cases to avoid doing a full 2p+2 precision calculation.
- relates to
-
JDK-8233452 java.math.BigDecimal.sqrt() with RoundingMode.FLOOR results in incorrect result
- Closed