You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gilles Sadowski (Jira)" <ji...@apache.org> on 2019/11/03 02:15:00 UTC

[jira] [Updated] (NUMBERS-137) Suspicious special case in "log"

     [ https://issues.apache.org/jira/browse/NUMBERS-137?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gilles Sadowski updated NUMBERS-137:
------------------------------------
    Summary: Suspicious special case in "log"  (was: Supicious special case in "log")

> Suspicious 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
>            Priority: Major
>             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)