Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1541

ArrayUtils.contains() fails to handle Double.NaN

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.7, 3.10
    • Fix Version/s: 3.12.0
    • Component/s: lang.*
    • Labels:
      None

      Description

      ArrayUtils.contains(double[], double) does not handle Double.NaN correctly. That is, ArrayUtils.contains() returns false, even if the given array contains Double.NaN.

       For example, consider the following: 

      double[] a = new double[]{Double.NEGATIVE_INFINITY, Double.NaN, Double.POSITIVE_INFINITY};
      System.out.println(ArrayUtils.contains(a, Double.POSITIVE_INFINITY)); // true System.out.println(ArrayUtils.contains(a, Double.NEGATIVE_INFINITY)); // true System.out.println(ArrayUtils.contains(a, Double.NaN)); // false ?
      

       

       

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                anthonymaidment Anthony Maidment
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m