On Thu, 16 Oct 2025 16:25:40 GMT, Raffaello Giulietti <[email protected]>
wrote:
>> fabioromano1 has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Comment for error analysis
>
> src/java.base/share/classes/java/math/BigDecimal.java line 2160:
>
>> 2158: *
>> 2159: * <p>The preferred scale of the returned result is equal to
>> 2160: * {@code this.scale()/n}. The value of the returned result is
>
> I think the preferred scale should be ceiling(this.scale() / n).
> The IEEE 754 standard has a preferred exponent (negated scale) of
> floor(exp(this) / n).
Yes, but this is inconsistent with the definition of _preferred scale_ for
`BigDecimal.sqrt()`.
> src/java.base/share/classes/java/math/BigDecimal.java line 2181:
>
>> 2179: * @param mc the context to use.
>> 2180: * @return the {@code n}<sup>th</sup> root of {@code this}.
>> 2181: * @throws ArithmeticException if {@code n == 0 || n ==
>> Integer.MIN_VALUE}.
>
> Just out of curiosity, is there a technical reason for the restriction on
> MIN_VALUE?
Yes, `|Integer.MIN_VALUE|` is out of range of `int`s, so it cannot be used as a
degree for `BigInteger.nthRoot(int)`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27148#discussion_r2437243194
PR Review Comment: https://git.openjdk.org/jdk/pull/27148#discussion_r2437253304