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

Suspicious special case in "log"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-beta1
    • complex
    • None

    Description

      In the implementation (copied below), two special cases return the same value.
      If intended, the two conditions should be grouped.

          public Complex log() {
              if (real == Double.POSITIVE_INFINITY &&
                  imaginary == Double.POSITIVE_INFINITY) {
                  return new Complex(Double.POSITIVE_INFINITY, PI_OVER_4);
              } else if (real == Double.POSITIVE_INFINITY &&
                         Double.isNaN(imaginary)) {
                  return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
              } else if (Double.isNaN(real) &&
                         imaginary == Double.POSITIVE_INFINITY) {
                  return new Complex(Double.POSITIVE_INFINITY, Double.NaN);
              }
              return new Complex(Math.log(abs()),
                                 Math.atan2(imaginary, real));
          }
      

      Attachments

        Issue Links

          Activity

            People

              aherbert Alex Herbert
              erans Gilles Sadowski
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: