RFR: 8341402: BigDecimal's square root optimization [v16]
fabioromano1
duke at openjdk.org
Fri Nov 15 14:07:50 UTC 2024
On Fri, 15 Nov 2024 13:22:32 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:
>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Code simplification
>
> src/java.base/share/classes/java/math/BigDecimal.java line 2190:
>
>> 2188: resultScale = strippedScale >> 1;
>> 2189: } else {
>> 2190: working = working.multiply(10L);
>
> While this is correct, there's useless work that is being performed.
>
> After the multiplication by 10, `working` cannot be an exact square, so this will fail later at L.2199.
> I wonder if this can be simplified to avoid the `multiply()` and the following `sqrtAndRemainder()` when `strippedScale` is odd.
I'm changing the code to take into account this fact.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21301#discussion_r1843855833
More information about the core-libs-dev
mailing list