On Wed, 8 Nov 2023 09:55:13 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> wrote:
>> 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. I think it's fine as is. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16457#discussion_r1386998599