RFR: 8341470: BigDecimal.stripTrailingZeros() optimization [v42]
fabioromano1
duke at openjdk.org
Sun Oct 13 16:21:12 UTC 2024
On Sun, 13 Oct 2024 16:06:34 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> What's really crucial for _correctness_ is to ensure maxPowsOf5 >= k.
>>
>> But for performance you also want maxPowsOf5 to be as small as possible. So, the fact that it turns out that maxPowsOf5 <= m + 1 guarantees that maxPowsOf5 is the best value that can be computed very efficiently. It's more a "quality of service" guarantee than anything fundamental.
>
> Perhaps leave m <= maxPowsOf5 <= m + 1 and maxPowsOf5 >= k and drop the note "and is never off by more than 1 from the theoretical m"
> What's really crucial for _correctness_ is to ensure maxPowsOf5 >= k.
Yes, I meant that the only way we know to ensure that condition is to ensure `m <= maxPowsOf5`...
> Perhaps leave m <= maxPowsOf5 <= m + 1 and maxPowsOf5 >= k and drop the note "and is never off by more than 1 from the theoretical m"
I would put `maxPowsOf5 <= m + 2` instead, because `maxPowsOf5 <= m + 1` is not obvious to prove mathematically...
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1798437787
More information about the core-libs-dev
mailing list