commons-issues mailing list archives

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

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

Gilles commented on NUMBERS-46:
-------------------------------

Please review the modifications:
commit 5a2f9d1492f0a9679c64a91d4e536b936fd815e4

> 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