On Sun, 13 Oct 2024 13:13:30 GMT, Raffaello Giulietti <[email protected]>
wrote:
>> fabioromano1 has updated the pull request incrementally with one additional
>> commit since the last revision:
>>
>> Minor change
>
> src/java.base/share/classes/java/math/BigDecimal.java line 5270:
>
>> 5268:
>> 5269: intVal = intVal.shiftRight(powsOf2); // remove powers of 2
>> 5270: // maxPowsOf5 >= floor(log5(intVal)) >= max{n : (intVal % 5^n)
>> == 0}
>
> Suggestion:
>
> // Let k = max{n : (intVal % 5^n) == 0}, m = max{n : 5^n <= intVal},
> so m >= k.
> // Let b = intVal.bitLength(). It can be shown that
> // | b * LOG_5_OF_2 - b log5(2) | < 2^(-21) (fp viz. real arithmetic),
> // which entails m <= maxPowsOf5 <= m + 1, where maxPowsOf5 is as
> below.
> // Hence, maxPowsOf5 >= k and is never off by more than 1 from the
> theoretical m.
@rgiulietti Good, but I would not put the inequality `maxPowsOf5 <= m + 1` and
say that `maxPowsOf5` is never off by more than 1 from the theoretical `m`,
because it is not crucial as `maxPowsOf5 >= k`, and because `m` is in function
of `intVal`, while `maxPowsOf5` is in function of `2^b`, so it is not obvious
that there's no power of five `pow` such that `intVal < pow < 2^b`...
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1798415994