RFR: 8356891: Some code simplifications for basic BigIntegers' bit operations
David Schlosnagle
duke at openjdk.org
Tue May 13 18:02:04 UTC 2025
On Sat, 10 May 2025 16:41:17 GMT, fabioromano1 <duke at openjdk.org> wrote:
> Some changes in `Biginteger`s' bit operations that increase the code readability and slightly optimize the execution time.
src/java.base/share/classes/java/math/BigInteger.java line 2642:
> 2640: }
> 2641: // (this.abs().bitLength() - 1L) * exponent + 1L > Integer.MAX_VALUE
> 2642: if (scaleFactor + bitsToShift - exponent >= Integer.MAX_VALUE) {
If this is overflow sensitive code, should this avoid adding on the left hand side?
Suggestion:
if (scaleFactor - exponent >= Integer.MAX_VALUE - bitsToShift) {
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25166#discussion_r2083701393
More information about the core-libs-dev
mailing list