RFR: 8341402: BigDecimal's square root optimization [v23]

Raffaello Giulietti rgiulietti at openjdk.org
Tue Nov 26 17:34:48 UTC 2024


On Tue, 26 Nov 2024 17:27:58 GMT, fabioromano1 <duke at openjdk.org> wrote:

>> I don't get your point. Here's an example:
>> 
>> BigDecimal.ONE.sqrt(new MathContext(2_000_000_000, RoundingMode.UP))
>> |  Exception java.lang.ArithmeticException: Overflow
>> |        at BigDecimal.sqrt (BigDecimal.java:2226)
>> |        at (#4:1)
>
>> I don't get your point. Here's an example:
>> 
>> ```
>> BigDecimal.ONE.sqrt(new MathContext(2_000_000_000, RoundingMode.UP))
>> |  Exception java.lang.ArithmeticException: Overflow
>> |        at BigDecimal.sqrt (BigDecimal.java:2226)
>> |        at (#4:1)
>> ```
> 
> Yes, that's correct indeed, I was wrongly assuming that `this.precision() >= minWorkingPrec`.

Also consider that my recent example works fine in the current implementation, returning 1.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21301#discussion_r1858970133


More information about the core-libs-dev mailing list