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

Suspicious special case in "log"

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: complex
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: