RFR of 8066842: java.math.BigDecimal.divide(BigDecimal, RoundingMode) produces incorrect result
brian.burkhalter at oracle.com
Fri Jan 16 21:18:18 UTC 2015
Please review at your convenience.
The problem appears to have been that at line 4941 of the old source, in the divWord() method, one or both of the long variables ‘r’ and ‘q’ overflowed the range of int so that information was lost when these variables were truncated to 32 bits. The code of divWord() seems to have been ported from a method of the same name in MutableBigInteger wherein its constraints were made explicit. In the patch, divWord() is replaced by divRemNegativeLong(), and the use of the former in divideAndRound128() replaced with inline code for the non-negative dividend cases, and by divRemNegativeLong() for the negative dividend cases.
More information about the core-libs-dev