RFR: 8077587: BigInteger Roots [v45]

fabioromano1 duke at openjdk.org
Fri Jul 25 15:20:58 UTC 2025


On Fri, 25 Jul 2025 14:56:47 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Round up to do less iterations
>>   
>>   With the 1st iteration outside the loop, it is more convenient rounding up to ceiling.
>
> src/java.base/share/classes/java/math/MutableBigInteger.java line 1934:
> 
>> 1932:             return new MutableBigInteger[] { this, new MutableBigInteger() };
>> 1933: 
>> 1934:         final int bitLength = (int) this.bitLength();
> 
> The method does not state that it is assuming that `bitLength()` fits in an `int`.

Indeed, I did not stated it because I was not sure if it were better to assume that `bitLength()` fits in an `int`, or to throw an `ArithmeticException` instead if it doesn't...

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24898#discussion_r2231398839


More information about the core-libs-dev mailing list