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

fp.bugs<1567> Floating point addition error

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description

      ###@###.### (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...

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: