commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <j...@apache.org>
Subject [jira] [Created] (NUMBERS-46) ContinuedFraction: "maxIterations" argument
Date Mon, 03 Jul 2017 13:54:00 GMT
Gilles created NUMBERS-46:
-----------------------------

             Summary: ContinuedFraction: "maxIterations" argument
                 Key: NUMBERS-46
                 URL: https://issues.apache.org/jira/browse/NUMBERS-46
             Project: Commons Numbers
          Issue Type: Bug
            Reporter: Gilles
            Assignee: Gilles
            Priority: Minor
             Fix For: 1.0


In class {{o.a.c.numbers.fraction.ContinuedFraction}}, method {{evaluate}} is declared as
{code}
public double evaluate(double x, double epsilon, int maxIterations)
{code}
Calling
{code}
cf.evaluate(x, eps, 1)
{code}
will raise an exception:
{noformat}
org.apache.commons.numbers.fraction.FractionException: maximal count (1) exceeded
{noformat}

At first sight, the check
{code}
if (n >= maxIterations) {
{code}
should rather be
{code}
if (n > maxIterations) {
{code}

However, it would also seem that the loop counter is wrong:
{code}
while (n < maxIterations) {
{code}
since setting {{maxIterations}} to 1 will in effect execute _zero_ iteration...




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message