On Sun, 13 Oct 2024 22:45:25 GMT, fabioromano1 <d...@openjdk.org> wrote:
>> An optimized algorithm for `BigDecimal.stripTrailingZeros()` that uses >> repeated squares trick. > > fabioromano1 has updated the pull request incrementally with one additional > commit since the last revision: > > Added mathematical comments for maxPowsOf5 Will approve in a couple of days if by then there are no other substantial changes. src/java.base/share/classes/java/math/BigDecimal.java line 5280: > 5278: BigInteger[] qr; // quotient-remainder pair > 5279: // Remove 5^(2^i) from the factors of intVal, until > 5^remainingZeros < 5^(2^i) > 5280: // (i.e., there are too few powers of five left to remove). It's a bit unclear what's meant here with "_too few_ powers of five left to remove". Can we have something more explicit? src/java.base/share/classes/java/math/BigDecimal.java line 5297: > 5295: // bitLength(remainingZeros) == min{n >= 0 : 5^(2^n) > > 5^remainingZeros} > 5296: // so, while the loop condition is true, > 5297: // the invariant i == max{n : 5^(2^n) <= 5^remainingZeros} Suggestion: // the invariant i == max{n : 5^(2^n) <= 5^remainingZeros}, // which is equivalent to i = bitLengthForLong(remainingZeros) - 1, ------------- PR Review: https://git.openjdk.org/jdk/pull/21323#pullrequestreview-2366952196 PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1799690935 PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1799691009