RFR: 8366478: BigDecimal roots

Raffaello Giulietti rgiulietti at openjdk.org
Thu Oct 23 17:13:04 UTC 2025


On Sat, 18 Oct 2025 16:26:42 GMT, fabioromano1 <duke at openjdk.org> wrote:

>> @fabioromano1 I think it is OK to have more efficient code even if the result is not correctly rounded.
>> Please add some code comment about your error analysis.
>
> @rgiulietti
>> * How much code would be needed to attain correct rounding in all modes?
> 
> I found a way to make the procedure for correct rounding deterministic, but it would complicate the code a lot, and of course it would be potentially expensive in terms of running time, since the number of additional digits to compute is finite but not bounded by a constant. So, if it were to be implemented, I think the choice to have a correct rounding should be left to the user.

@fabioromano1 The spec of `sqrt()` has just been [amended](https://github.com/openjdk/jdk/pull/27882) to use `ceilDiv(scale(), 2)` as the preferred scale.
Further, there's a preference for `rootn()` as the name the n-th root, rather than the existing `nthRoot()`.

Could you please adapt your PR?
I'll resume review soon.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27148#issuecomment-3438158390


More information about the core-libs-dev mailing list