RFR: 8355992: Add unsignedMultiplyExact and *powExact methods to Math and StrictMath [v2]
fabioromano1
duke at openjdk.org
Fri May 2 17:30:48 UTC 2025
On Fri, 2 May 2025 17:18:36 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
> Anyway, since the pre-checks are not precise, that would lead to an implementation with a loop with checked, and another one with unchecked multiplications. I don't think this buys you anything.
It serves to skip the checks in the loop if in the common cases the length of the results are way more little with respect to `Long.SIZE` and to fail fast if in the common cases the length of the results are way more bigger than `Long.SIZE`.
> @fabioromano1 Well, there are two checks. In one the product can overflow, you'd need to convert one of the operands to `long`.
If the condition at point 1 is evaluated only if the condition at point 2 is false, then it can never overflow.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25003#discussion_r2071929231
More information about the core-libs-dev
mailing list