AmarGhugare opened a new pull request, #1876:
URL: https://github.com/apache/commons-lang/pull/1876

   Negative powers construct a reciprocal before reducing the operand, so an 
`Integer.MIN_VALUE` numerator can cause an overflow exception even when the 
result fits:
   
   ```java
   Fraction.getFraction(Integer.MIN_VALUE, 2).pow(-1); // -1/1073741824
   Fraction.getFraction(Integer.MIN_VALUE, 1073741824).pow(-2); // 1/4
   ```
   
   Reduce before inversion for this numerator, then use the existing power 
calculation. Ordinary unreduced results, including `6/10` raised to `-1` 
returning `10/6`, retain their tested behavior. Standalone `invert()` is 
unchanged.
   
   Eight representable-result cases throw without the fix. Regression tests 
cover these results and four genuine-overflow cases. Full validation passed on 
JDK 25.0.4.1 using `mvn -o -B -ntp -DheapSize=-Xmx1G`: 119,340 tests run, zero 
failures/errors, and 18 skipped. Coverage, license checks, Checkstyle, binary 
compatibility, SpotBugs, PMD, and Javadoc checks passed.
   
   This is separate from the division correction in #1865. The broader 
performance proposal #611 still calls `invert()` directly for exponent `-1`.
   
   Jira filing is pending approval of the Apache Jira account. The reproduction 
and proposed fix are included here for review in the meantime.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to