RFR: 8341402: BigDecimal's square root optimization [v2]

fabioromano1 duke at openjdk.org
Thu Oct 3 09:12:37 UTC 2024


On Thu, 3 Oct 2024 07:55:26 GMT, fabioromano1 <duke at openjdk.org> wrote:

>> Without experimenting a bit, it's hard to tell.
>> Anyway, I believe the current implementation of `stripZerosToMatchScale()` is O(n^2) rather than exponential, because each single division by 10 is linear.
>> 
>> But let's focus on `sqrt()` in this PR and leave `stripZerosToMatchScale()` for another time.
>
> @rgiulietti  I tried to implement and test stripping zeros  algorithm with repeated squares trick, and on my laptop it takes around two seconds for strip one million of zeros. So, I decided to remove the method `stripZerosToEvenScale()`, in order to use only the `stripZerosToMatchScale()` logic.

@fabioromano1 I agree with starting a new PR for speed up `stripZerosToMatchScale()`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21301#discussion_r1785890823


More information about the core-libs-dev mailing list