RFR: 8077587: BigInteger Roots [v23]
Raffaello Giulietti
rgiulietti at openjdk.org
Wed Jul 16 10:04:48 UTC 2025
On Sat, 12 Jul 2025 09:18:27 GMT, fabioromano1 <duke at openjdk.org> wrote:
>> This PR implements nth root computation for BigIntegers using Newton method.
>
> 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/BigInteger.java line 2755:
> 2753: * is even and this BigInteger is negative, an {@code ArithmeticException} will be
> 2754: * thrown.
> 2755: *
I think this specification is a bit confusing.
For example, when x = -10 and n = 2, then y = -3 has the same sign of x and its magnitude r = 3 is the largest integer meeting r^n ≤ |x|. However, y is not a solution. Sure, there's the note about negative x and even n, but that should emerge as a property from the definition, not as an additional condition.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2209865612
More information about the core-libs-dev
mailing list