On Tue, 5 May 2026 15:00:07 GMT, fabioromano1 <[email protected]> wrote:

>> An implementation of `BigDecimal.nthRoot(int, MathContext)`.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> fabioromano1 has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 40 commits:
> 
>  - Merge branch 'openjdk:master' into 8366478
>  - Update since version
>  - Handle negative degrees differently to simplify and optimize code
>  - Simplified result's assertions for n < 0
>  - Some code simplifications
>  - Added further tests and optimized result assertions
>  - Correct for loop of precision in two digit tests
>  - Added one digit tests to cover new paths
>  - Added tests for exact result cases and handle result assertions for n < 0
>  - Correct error output message
>  - ... and 30 more: https://git.openjdk.org/jdk/compare/70f20f9b...2531883c

Otherwise looks fine to me.

src/java.base/share/classes/java/math/BigDecimal.java line 2259:

> 2257:             }
> 2258:             // Test numerical properties at full precision before any 
> scale adjustments.
> 2259:             assert rootnResultAssertions(result, mc, n);

As you might be aware, `assert` only throws when assertions are enabled on the 
command line.

If you want a stronger way to "assert", you should `throw new 
AssertionError(...)` in the usual way.

test/jdk/java/math/BigDecimal/SquareRootTests.java line 102:

> 100:                 for (int n = -4; n <= 4; n += 2) {
> 101:                     try {
> 102:                         BigDecimal result = 
> input.sqrt(MathContext.DECIMAL64);

@fabioromano1 Shouldn't this be an invocation to `rootn()`?

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

PR Review: https://git.openjdk.org/jdk/pull/27148#pullrequestreview-4236857922
PR Review Comment: https://git.openjdk.org/jdk/pull/27148#discussion_r3196155220
PR Review Comment: https://git.openjdk.org/jdk/pull/27148#discussion_r3196135846

Reply via email to