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

fp.bugs<1567> Floating point addition error

XMLWordPrintable

    • x86
    • windows_nt

      ###@###.### (Mat Nelson)

      Description:
      I was writing an applet that starts with a float value of 0.0 and repeatedly adds .1 to it. Occasionally java would add .09999 or .10001 instead. Here is the source to reproduce the problem

      0class DemonstrateFloatProblem p public static void main(String argsPP) p float x 0 0.00 for (int i 0 00i010000i ) p System.out.println(x)0 x 0 x .10 or x 0 .1 p pp

      Error Message:
      (well... here is some of the output I get...)...7.57.67.77.799997.899997.999998.099998.28.3...

            fyellinsunw Frank Yellin (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: