-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
14
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Windows 10. Java 14.
A DESCRIPTION OF THE PROBLEM :
The problem is that BigDecimal throws an ArithmeticException when asked to compute 40 divided by 60. The exception thrown is as follows: "Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result."
This is clearly wrong. The answer to 40 divided by 60 is 0.64. Which is a terminating decimal.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Enter the following program:
public class BigDecimalBug() {
public static void main(String[] args) {
BigDecimal a = new BigDecimal(40);
BigDecimal b = new BigDecimal(60);
System.out.println(a.divide(b));
}
}
ACTUAL -
Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result."
---------- BEGIN SOURCE ----------
public class BigDecimalBug() {
public static void main(String[] args) {
BigDecimal a = new BigDecimal(40);
BigDecimal b = new BigDecimal(60);
System.out.println(a.divide(b));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
FREQUENCY : often
Windows 10. Java 14.
A DESCRIPTION OF THE PROBLEM :
The problem is that BigDecimal throws an ArithmeticException when asked to compute 40 divided by 60. The exception thrown is as follows: "Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result."
This is clearly wrong. The answer to 40 divided by 60 is 0.64. Which is a terminating decimal.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Enter the following program:
public class BigDecimalBug() {
public static void main(String[] args) {
BigDecimal a = new BigDecimal(40);
BigDecimal b = new BigDecimal(60);
System.out.println(a.divide(b));
}
}
ACTUAL -
Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result."
---------- BEGIN SOURCE ----------
public class BigDecimalBug() {
public static void main(String[] args) {
BigDecimal a = new BigDecimal(40);
BigDecimal b = new BigDecimal(60);
System.out.println(a.divide(b));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
FREQUENCY : often