On Wed, 8 Nov 2023 00:23:22 GMT, Brian Burkhalter <b...@openjdk.org> wrote:
>> Raffaello Giulietti has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Using repeat() instead of loop. > > src/java.base/share/classes/java/math/BigDecimal.java line 3510: > >> 3508: : intVal.toString(); >> 3509: int len = str.length() + trailingZeros; >> 3510: if (len < 0) { > > One could use `Math.addExact`, which has an intrinsic, and convert any thrown > `ArithmeticException` into an OOME but I am not sure it's worth it. Yes, I considered that but I'm not sure how the throwing and catching of `ArithmeticException` with `*Exact` intrinsics is optimized by C2, so I have a manual overflow check for the addition. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16457#discussion_r1386307618