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

ArrayUtils.contains() fails to handle Double.NaN

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.7, 3.10
    • 3.12.0
    • lang.*
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            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

                Slack

                  Issue deployment