-
Bug
-
Resolution: Fixed
-
P3
-
11, 14
-
b32
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8237292 | 15 | Joe Darcy | P3 | Resolved | Fixed | b07 |
JDK-8237700 | 14.0.2 | Joe Darcy | P3 | Resolved | Fixed | master |
JDK-8238126 | 14.0.1 | Unassigned | P3 | Resolved | Fixed | b02 |
JDK-8256759 | 13.0.6 | Yuri Nesterenko | P3 | Resolved | Fixed | b01 |
JDK-8244070 | 11.0.9-oracle | Fisba Samreen | P3 | Resolved | Fixed | b01 |
JDK-8246655 | 11.0.9 | Joe Darcy | P3 | Resolved | Fixed | b01 |
Also tested OpenJDK 11.0.2 with the same result.
A DESCRIPTION OF THE PROBLEM :
The method java.math.BigDecimal.sqrt(MathContext mc) does not respect the intention of RoundingMode.FLOOR.
Other RoundingMode values have not been tested, but may also return incorrectly rounded results.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the simple source code snippet in a main method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1.99999999999
ACTUAL -
2.00000000000
---------- BEGIN SOURCE ----------
MathContext mc = new MathContext(12, RoundingMode.FLOOR);
System.out.println(new BigDecimal("3.999999999999999999999999999999").sqrt(mc));
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Using the sqrt() method of the bigmath library from https://github.com/eobermuhlner/big-math does deliver the correct result.
FREQUENCY : always
- backported by
-
JDK-8237292 java.math.BigDecimal.sqrt() with RoundingMode.FLOOR results in incorrect result
- Resolved
-
JDK-8237700 java.math.BigDecimal.sqrt() with RoundingMode.FLOOR results in incorrect result
- Resolved
-
JDK-8238126 java.math.BigDecimal.sqrt() with RoundingMode.FLOOR results in incorrect result
- Resolved
-
JDK-8244070 java.math.BigDecimal.sqrt() with RoundingMode.FLOOR results in incorrect result
- Resolved
-
JDK-8246655 java.math.BigDecimal.sqrt() with RoundingMode.FLOOR results in incorrect result
- Resolved
-
JDK-8256759 java.math.BigDecimal.sqrt() with RoundingMode.FLOOR results in incorrect result
- Resolved
- relates to
-
JDK-8237801 Refine Netwon iteration termination conditions for BigDecimal.sqrt
- Open
-
JDK-4851777 Add BigDecimal sqrt method
- Closed