commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Nickerson (JIRA)" <>
Subject [jira] [Created] (NUMBERS-48) Unreachable statements in Complex.abs()
Date Thu, 03 Aug 2017 17:18:00 GMT
David Nickerson created NUMBERS-48:

             Summary: Unreachable statements in Complex.abs()
                 Key: NUMBERS-48
             Project: Commons Numbers
          Issue Type: Bug
    Affects Versions: 1.1
            Reporter: David Nickerson
            Priority: Minor
         Attachments: complex_abs.patch

This return statement in Complex.abs() is unreachable:

if (FastMath.abs(real) < FastMath.abs(imaginary)) {
  if (imaginary == 0.0) {
    return FastMath.abs(real);

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

View raw message