Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7093777

Float.parseFloat does not round correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • core-libs
    • x86
    • linux_ubuntu

      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 ----------

            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: