Uploaded image for project: 'Commons Numbers'
  1. Commons Numbers
  2. NUMBERS-60

Check Javadoc with respect to NaN

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.0-beta1
    • complex

    Description

      See e.g. the doc for method negate:

      /**
       * Returns a {@code Complex} whose value is {@code (-this)}.
       * Returns {@code NaN} if either real or imaginary
       * part of this complex number is {@code Double.NaN}.
       *
       * @return {@code -this}.
       */
      public Complex negate() {
          return new Complex(-real, -imaginary);
      }
      

      The "NaN" advertized in the the Javadoc seems to refer to the Complex.NaN field, but negate is able to construct instances for which the contract of method equals(Object) will be broken.

      As a related issue, I would make the NaN field "private" (and rename it "NAN" to avoid the CheckStyle warning); users who need to check for (any combination of) NaN should use the isNaN() method.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              erans Gilles Sadowski
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: