On Mon, Jul 14, 2025 at 10:14 AM fabioromano1 <d...@openjdk.org> wrote:
>
> On Sat, 12 Jul 2025 09:18:27 GMT, fabioromano1 <d...@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
>
> The integers are closed under positive powers, and not under positive
nthRoots, this is true. However, the problem remains, as if the root degree
`n` is negative, then for radicands that are not 1, -1 or 0 we should
return 0, and zero raised to a negative exponent is undefined in real
numbers, and so the remainder is.
>
Good point. But by that argument nthRoot(int n) should still be
well-defined. And the comment for nthRootAndRemainder still looks wrong to
me

>From the spec, we can take the answer to be "(x.signum() *
floor(abs(nthRoot(x, n)))), where nthRoot(x, n) denotes the real nth root
of x treated as a real".

This means that e.g. the (-3)rd root of 2, is floor(abs(nthRoot(2, -3))),
nthRoot(2, -3) is presumably 1 / nthRoot(2, 3), which is 0.79... So if we
take this as the definition, the answer is clearly 0, which is perfectly
well-defined.

Again, I'm not arguing for a functional change. I just don't like the spec
comments.

Reply via email to