RFR: 8077587: BigInteger Roots [v23]
fabioromano1
duke at openjdk.org
Mon Jul 14 15:42:45 UTC 2025
On Mon, 14 Jul 2025 14:33:26 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Removed useless instruction
>
> src/java.base/share/classes/java/math/MutableBigInteger.java line 1964:
>
>> 1962: final double rad = Math.nextUp(x >= 0 ? x : x + 0x1p64);
>> 1963: final double approx = n == 3 ? Math.cbrt(rad) : Math.pow(rad, Math.nextUp(1.0 / n));
>> 1964: long rLong = (long) Math.ceil(Math.nextUp(approx));
>
> Does `rLong` need to be an overestimate of the true value, or does the algorithm also works for underestimates?
> I'm asking because I'm not sure that `Math.pow()` has strong guarantees about its error bounds, whatever the documentation states.
@rgiulietti The convergence of the recurrence is guaranteed if the initial estimate is larger than or equal to the exact value, AFAIK no guarantee is given when the estimate is smaller than the exact value.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2205244158
More information about the core-libs-dev
mailing list