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

Incorrect value of sum 2.0+0.9999 = 2.9999000000000002

XMLWordPrintable

    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      windows 10

      A DESCRIPTION OF THE PROBLEM :
      Please run below code in java 8 :

      public static void main(String[] args)
          {
              System.out.println(2.0 + 0.9999);
          }

      The sum was expected to be 2.9999 but found 2.9999000000000002

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just run this :

      public static void main(String[] args)
          {
              System.out.println(2.0 + 0.9999);
          }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      2.9999
      ACTUAL -
      2.9999000000000002

      ---------- BEGIN SOURCE ----------
      class Test
      {
          public static void main(String[] args)
          {
              System.out.println(2.0 + 0.9999);
          }
      }

      ---------- END SOURCE ----------

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: