FULL PRODUCT VERSION :
OpenJDK Runtime Environment (IcedTea6 1.10.2) (6b22-1.10.2-0ubuntu1~11.04.1)
ADDITIONAL OS VERSION INFORMATION :
Linux gowers 2.6.38-11-generic-pae #48-Ubuntu SMP Fri Jul 29 20:51:21 UTC 2011 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Float.parseFloat does not round correctly in some cases, and can even be nonmonotonic. Naturally, this affects the compiler as well as compiled programs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the below-provided source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the above to print "true", since 144115196665790480 <= 144115196665790481.
ACTUAL -
The above prints "false".
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Foo {
public static void main(String[] args) {
System.out.println(144115196665790480f <= 144115196665790481f);
}
}
---------- END SOURCE ----------
OpenJDK Runtime Environment (IcedTea6 1.10.2) (6b22-1.10.2-0ubuntu1~11.04.1)
ADDITIONAL OS VERSION INFORMATION :
Linux gowers 2.6.38-11-generic-pae #48-Ubuntu SMP Fri Jul 29 20:51:21 UTC 2011 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Float.parseFloat does not round correctly in some cases, and can even be nonmonotonic. Naturally, this affects the compiler as well as compiled programs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the below-provided source code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect the above to print "true", since 144115196665790480 <= 144115196665790481.
ACTUAL -
The above prints "false".
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Foo {
public static void main(String[] args) {
System.out.println(144115196665790480f <= 144115196665790481f);
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6358355 Direct String-to-float conversion does not preserve monotonicity
- Closed