RFR: 8367603: Optimize exact division in BigDecimal [v14]
fabioromano1
duke at openjdk.org
Wed Sep 24 20:15:00 UTC 2025
On Wed, 24 Sep 2025 12:26:32 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Small optimizations
>
> src/java.base/share/classes/java/math/BigDecimal.java line 5166:
>
>> 5164: // Since b log5(2) > m, log5(2)+2^(-21) < 1/2
>> 5165: // and (b-1) * LOG_5_OF_2 > [b log5(2) - log5(2)] - 2^(-21),
>> 5166: // then m <= Math.round((b - 1) * LOG_5_OF_2) <= m + 1 follows.
>
> Not sure that the inequalities above also show the `<= m + 1` part
@rgiulietti Since `x >= 2^(b - 1)`, then `(b - 1) * log5(2) < m + 1`, and so `Math.round((b - 1) * LOG_5_OF_2) <= m + 1`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27271#discussion_r2376948107
More information about the core-libs-dev
mailing list