commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles Sadowski (Jira)" <j...@apache.org>
Subject [jira] [Created] (NUMBERS-137) Supicious special case in "log"
Date Thu, 03 Oct 2019 14:54:00 GMT
Gilles Sadowski created NUMBERS-137:
---------------------------------------

             Summary: Supicious special case in "log"
                 Key: NUMBERS-137
                 URL: https://issues.apache.org/jira/browse/NUMBERS-137
             Project: Commons Numbers
          Issue Type: Bug
          Components: complex
            Reporter: Gilles Sadowski
             Fix For: 1.0


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

{code}
    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));
    }
{code}




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message