On Tue, 19 Nov 2024 19:02:09 GMT, fabioromano1 <d...@openjdk.org> wrote:
>> src/java.base/share/classes/java/math/BigDecimal.java line 2253: >> >>> 2251: >>> 2252: case UP, CEILING -> { >>> 2253: BigInteger[] sqrtRem = >>> workingInt.sqrtAndRemainder(); >> >> Can't this follow the same logic as for the halfway cases, with just >> `sqrt()` and a `!workingInt.equals(sqrt.multiply(sqrt))` test? This would >> increase consistency. >> Are there performance reasons to do it as in the current code? > > Yes, indeed in this case the remainder is always needed, so invoking > `workingInt.sqrtAndRemainder()` is faster than checking > `!workingInt.equals(sqrt.multiply(sqrt))`, as it avoids the squaring of > `sqrt`. I see. I have no other comments on the code. I look forward for the tests. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21301#discussion_r1848971914