You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2022/10/14 11:34:00 UTC

[jira] [Closed] (NUMBERS-46) ContinuedFraction: "maxIterations" argument

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

Alex Herbert closed NUMBERS-46.
-------------------------------
    Resolution: Fixed

> ContinuedFraction: "maxIterations" argument
> -------------------------------------------
>
>                 Key: NUMBERS-46
>                 URL: https://issues.apache.org/jira/browse/NUMBERS-46
>             Project: Commons Numbers
>          Issue Type: Bug
>          Components: fraction
>            Reporter: Gilles Sadowski
>            Assignee: Gilles Sadowski
>            Priority: Minor
>             Fix For: 1.0-beta1
>
>
> 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
(v8.20.10#820010)