RFR: 8366478: BigDecimal roots
Raffaello Giulietti
rgiulietti at openjdk.org
Sat Oct 18 17:52:03 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 Thanks for investigating. I'd stick with the current solution for now.
BTW, @jddarcy opened a [PR](https://github.com/openjdk/jdk/pull/27882) for the preferred scale in `sqrt()`, so there might be a need to change the spec and implementation slightly.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27148#issuecomment-3418697999
More information about the core-libs-dev
mailing list