Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8264161: BigDecimal#stripTrailingZeros can throw undocumented ArithmeticException #3189

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -3090,6 +3090,7 @@ public BigDecimal scaleByPowerOfTen(int n) {
*
* @return a numerically equal {@code BigDecimal} with any
* trailing zeros removed.
* @throws ArithmeticException (overflow) if the new scale is out of range.
* @since 1.5
*/
public BigDecimal stripTrailingZeros() {
@@ -4921,6 +4922,7 @@ private static boolean needIncrement(MutableBigInteger mdivisor, int roundingMod
*
* @return new {@code BigDecimal} with a scale possibly reduced
* to be closed to the preferred scale.
* @throws ArithmeticException (overflow) if the new scale is out of range.
*/
private static BigDecimal createAndStripZerosToMatchScale(BigInteger intVal, int scale, long preferredScale) {
BigInteger qr[]; // quotient-remainder pair
@@ -4945,6 +4947,7 @@ private static BigDecimal createAndStripZerosToMatchScale(BigInteger intVal, int
*
* @return new {@code BigDecimal} with a scale possibly reduced
* to be closed to the preferred scale.
* @throws ArithmeticException (overflow) if the new scale is out of range.
*/
private static BigDecimal createAndStripZerosToMatchScale(long compactVal, int scale, long preferredScale) {
while (Math.abs(compactVal) >= 10L && scale > preferredScale) {