RFR: 8366478: BigDecimal roots

fabioromano1 duke at openjdk.org
Sat Oct 18 16:29:03 UTC 2025


On Wed, 15 Oct 2025 15:17:56 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> @rgiulietti 
>>> * How much code would be needed to attain correct rounding in all modes?
>> 
>> The best that can be done is to make the probability of an incorrect rounding as small as desired, but this can be computationally expensive: a probability within $10^{-k}$ means that the integer root must have $k$ more digits, and so the radicand must have $n \cdot k$ more digits.
>
> @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, the choice to have a correct rounding could be left to the user.

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

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


More information about the core-libs-dev mailing list