Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7098025

FindBugs violations: Doomed test for equality to NaN

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • jt4.4.1
    • jt4.4.1
    • tools
    • b05
    • b05
    • generic
    • generic
    • Verified

    Description

      This code checks to see if a floating point value is equal to the special Not A Number value (e.g., if (x == Double.NaN)). However, because of the special semantics of NaN, no value is equal to Nan, including NaN. Thus, x == Double.NaN always evaluates to false. To check to see if a value contained in x is the special Not A Number value, use Double.isNaN(x) (or Float.isNaN(x) if x is floating point precision).

      FE: In class com.sun.javatest.Harness
      In class com.sun.javatest.Harness
      In method com.sun.javatest.Harness.runTests(Parameters, boolean)
      At Harness.java:[line 631]

      Attachments

        Activity

          People

            ersh Mikhail Ershov (Inactive)
            ersh Mikhail Ershov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: