RFR: 8341470: BigDecimal.stripTrailingZeros() optimization [v33]

Raffaello Giulietti rgiulietti at openjdk.org
Fri Oct 11 19:04:17 UTC 2024


On Fri, 11 Oct 2024 18:55:28 GMT, fabioromano1 <duke at openjdk.org> wrote:

>>> If the mathematical value v of the product and its floating-point value fp are separated by an integer i in such a way that fp < i < v, we are in trouble: the ceilings will be different, even if the values are very close to each other.
>> 
>> In that unlikely case, we would have `maxPowsOf5 >= floor(log5(intVal))`, which is still acceptable as an upper bound.
>
> And considering that `Math.round()` rounds to the closest integer, it also should assure `maxPowsOf5 >= floor(log5(intVal))`, giving a better upper bound.

As I asked above, what's the property that should hold?
5^`maxPowsOf5` <= `intVal` < 5^(`maxPowsOf5` + 1)?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21323#discussion_r1797327607


More information about the core-libs-dev mailing list