On Sun, 13 Oct 2024 16:57:33 GMT, fabioromano1 <d...@openjdk.org> wrote:
>> It can be proven by considering >> >> - the inequality | b * LOG_5_OF_2 - b log5(2) | < 2^(-21) >> - the properties of round() (to an integer) >> - log5(2) < 1/2 >> >> The last one is crucial for the upper bound to be m + 1 rather than m + 2. >> >> Feel free to use m + 2, though. > > I understood that it follows from the fact that `log5(2^(n+1)) - log5(2^n) == > [log5(2^n) + log5(2)] - log5(2^n)`, but I think it's superfluous having to > explain it in the comments just to prove `maxPowsOf5 <= m + 1`, while it is > more clear to understand why `maxPowsOf5 <= m + 2` is true. Anyway, thanks > for the insight. With the notation above, the reasoning goes like so: 2^(b-1) <= v < 5^(m+1), hence b log5(2) < m + 1 + log5(2). This implies b * LOG_5_OF_2 < m + 1 + log5(2) + 2^(-21) < m + 1 + 1/2, which leads to round(b * LOG_5_OF_2) <= m + 1. As said, I don't mind if you prefer m + 2. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1798522972