RFR: 8366478: BigDecimal roots

fabioromano1 duke at openjdk.org
Wed Oct 15 10:44:42 UTC 2025


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

>> @rgiulietti Here is the PR.
>
> @fabioromano1 In the comments there are claims about the relative errors. Two questions arise:
> * How were the bounds determined? There seems to be no indication in the comments provided so far.
> * How much code would be needed to attain correct rounding in all modes?

@rgiulietti 
> * How were the bounds determined? There seems to be no indication in the comments provided so far.

In case of `n < 0` and no halfway rounding, the root's inversion gives an error of 1 ulp, that's why we add one more digit to the integer root, so that the integer root has an error of 0.1 ulps, and therefore the error of the inverted root is 1+0.1 ulps. Same reasoning for halfway rounding gives half of the error just found.
> * How much code would be needed to attain correct rounding in all modes?

If `n > 0`, the PR code already gives correct rounding in all modes, but in case of `n < 0`, I'm afraid there's no way to have always correct rounding, due to table maker's dilemma.

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

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


More information about the core-libs-dev mailing list