-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8, 11, 17, 18
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
The math problem 2.4%0.2 (2.4 modulo 0.2) return 0.2, while the problem 3.2%0.2 returns 0.
This is true for many cases of floating point modulo and should have all kinds of very negative effects in all sorts of software.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
System.out.println((2.4%0.2)+""); //return 0.2
System.out.println((3.2%0.2)+""); //returns 0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2.4%0.2 and 3.2%0.2 should always return 0
ACTUAL -
result is 0.2, which is clearly not the case
---------- BEGIN SOURCE ----------
System.out.println((2.4%0.2)+""); //return 0.2
System.out.println((3.2%0.2)+""); //returns 0
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
BigDecimal can be used.
FREQUENCY : always
The math problem 2.4%0.2 (2.4 modulo 0.2) return 0.2, while the problem 3.2%0.2 returns 0.
This is true for many cases of floating point modulo and should have all kinds of very negative effects in all sorts of software.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
System.out.println((2.4%0.2)+""); //return 0.2
System.out.println((3.2%0.2)+""); //returns 0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
2.4%0.2 and 3.2%0.2 should always return 0
ACTUAL -
result is 0.2, which is clearly not the case
---------- BEGIN SOURCE ----------
System.out.println((2.4%0.2)+""); //return 0.2
System.out.println((3.2%0.2)+""); //returns 0
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
BigDecimal can be used.
FREQUENCY : always
- duplicates
-
JDK-8279489 Math.pow function does not give correct result for fractional base and exponent
- Closed
- relates to
-
JDK-8285626 javax.script.ScriptEngine eval gives wrong digits for decimal multiplication
- Closed