On Thu, 3 Oct 2024 17:11:09 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: > > Code simplification src/java.base/share/classes/java/math/BigDecimal.java line 5238: > 5236: BigInteger pow = FIVE_TO_2_TO[FIVE_TO_2_TO_LEN - 1]; > 5237: for (int i = FIVE_TO_2_TO_LEN; i <= n; i++) > 5238: FIVE_TO_2_TO[i] = pow = pow.multiply(pow); Drive-by comment... apologies if I'm missing some subtle context. Doesn't this raciness create a bug? The field `FIVE_TO_2_TO_LEN` is read multiple times, and other threads could be incrementing it while this code executes, which would lead to an incorrect value for `pow`, etc. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1786580894