JDK-7093777 : Float.parseFloat does not round correctly
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux_ubuntu
  • CPU: x86
  • Submitted: 2011-09-22
  • Updated: 2012-03-20
  • Resolved: 2011-09-22
Related Reports
Duplicate :  
Description
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 ----------

Comments
EVALUATION Closing as duplicate of 6358355.
22-09-2011