[9] RFR of 8066842: java.math.BigDecimal.divide(BigDecimal, RoundingMode) produces incorrect result

Brian Burkhalter brian.burkhalter at oracle.com
Fri Jan 16 21:18:18 UTC 2015


Please review at your convenience.

Issue:	https://bugs.openjdk.java.net/browse/JDK-8066842
Patch:	http://cr.openjdk.java.net/~bpb/8066842/webrev.00/

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 mailing list