RFR: 8355992: Add unsignedMultiplyExact and *powExact methods to Math and StrictMath [v2]
Raffaello Giulietti
rgiulietti at openjdk.org
Fri May 2 16:25:46 UTC 2025
On Fri, 2 May 2025 16:07:31 GMT, fabioromano1 <duke at openjdk.org> wrote:
>> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Clearer and more complete spec of the *pow* methods.
>
> src/java.base/share/classes/java/lang/Math.java line 3567:
>
>> 3565: return 1;
>> 3566: }
>> 3567: if (x == 0 || x == 1) {
>
> Suggestion:
>
> if (x == 0 || x == 1 || n == 1) {
@fabioromano1 Unless there's evidence that these cases are _very very_ common, there's no point in adding fast paths.
See this comment in `unsignedPowExact(long,int)`
/*
* To keep the code as simple as possible, there are intentionally
* no fast paths, except for |x| <= 1.
* The reason is that the number of loop iterations below can be kept
* very small when |x| > 1, but not necessarily when |x| <= 1.
*/
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25003#discussion_r2071857047
More information about the core-libs-dev
mailing list