On Thu, 3 Oct 2024 07:55:26 GMT, fabioromano1 <d...@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. Nice! Perhaps it would make sense to have your new implementation of `stripZerosToMatchScale()` in another PR, integrate that one first, and then come back to this PR. For general usage of `BigDecimal`, its more useful to have a faster `stripZerosToMatchScale()` than a faster `sqrt()`, I think. Let me know if you agree of if you prefer to go ahead with with PR first. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21301#discussion_r1785883833