commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Barnhill (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NUMBERS-48) Unreachable statements in Complex.abs()
Date Fri, 26 Jan 2018 14:01:00 GMT

    [ https://issues.apache.org/jira/browse/NUMBERS-48?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16341085#comment-16341085
] 

Eric Barnhill commented on NUMBERS-48:
--------------------------------------

Ah right. I just forked commons-statistics so my head was in the wrong place.

> Unreachable statements in Complex.abs()
> ---------------------------------------
>
>                 Key: NUMBERS-48
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-48
>             Project: Commons Numbers
>          Issue Type: Bug
>            Reporter: David Nickerson
>            Priority: Minor
>              Labels: easyfix, newbie, patch
>             Fix For: 1.0
>
>         Attachments: complex_abs.patch
>
>
> This return statement in Complex.abs() is unreachable:
> {code:java}
> if (FastMath.abs(real) < FastMath.abs(imaginary)) {
>   if (imaginary == 0.0) {
>     return FastMath.abs(real);
>   }
> {code}
> If imaginary == 0, then there's no way that the preceding condition would be true. There
are two similar inner 'if' statements that were accidentally switched. Returned values are
still correct, but performance suffers.
> The attached patch switches these back. Note that we're still protected from dividing
by zero.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message