On Wed, 16 Jul 2025 10:01:00 GMT, Raffaello Giulietti <rgiulie...@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/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. I don't know other ways to define it that don't involve the clause `!(x < 0 && n % 2 == 0)`. If the first definition is confusing, the only solution I see is to remove it, and leave only the formula `(x.signum() * floor(abs(nthRoot(x, n))))`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2209939998