RFR: 8341402: BigDecimal's square root optimization
fabioromano1
duke at openjdk.org
Wed Oct 2 18:35:36 UTC 2024
On Wed, 2 Oct 2024 18:16:06 GMT, Raffaello Giulietti <rgiulietti 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.
Yes, it is linear, but in the length of the magnitude, while it is exponential in the length of the precision... (`1_000_000` of divisions for a precision of 7 digits)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21301#discussion_r1785059976
More information about the core-libs-dev
mailing list