On Fri, 28 Mar 2025 18:24:49 GMT, fabioromano1 <d...@openjdk.org> wrote:

>> After changing `BigInteger.sqrt()` algorithm, this can be also used to speed 
>> up `BigDecimal.sqrt()` implementation. Here is how I made it.
>> 
>> The main steps of the algorithm are as follows:
>> first argument reduce the value to an integer using the following relations:
>> 
>> x = y * 10 ^ exp
>> sqrt(x) = sqrt(y) * 10^(exp / 2) if exp is even
>> sqrt(x) = sqrt(y*10) * 10^((exp-1)/2) is exp is odd
>> 
>> Then use BigInteger.sqrt() on the reduced value to compute the numerical 
>> digits of the desired result.
>> 
>> Finally, scale back to the desired exponent range and perform any adjustment 
>> to get the preferred scale in the representation.
>
> fabioromano1 has updated the pull request with a new target base due to a 
> merge or a rebase. The incremental webrev excludes the unrelated changes 
> brought in by the merge/rebase. The pull request contains 36 additional 
> commits since the last revision:
> 
>  - Merge branch 'openjdk:master' into patchBigDecimalSqrt
>  - An optimization
>  - Refine documentation
>  - Speed up computation of bitLength()
>  - An optimization
>  - Make digitLengthLower() static
>  - Optimization for integer BigDecimals detection
>  - Optimized integer BigDecimals detection
>  - Added test for scale overflow
>  - Added tests for exact results path
>  - ... and 26 more: https://git.openjdk.org/jdk/compare/b917598c...378569c5

@fabioromano1 Thanks so much for your great work and patience!

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

Marked as reviewed by rgiulietti (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/21301#pullrequestreview-2756665611

Reply via email to