Uploaded image for project: 'Commons Numbers'
  1. Commons Numbers
  2. NUMBERS-46

ContinuedFraction: "maxIterations" argument

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.0-beta1
    • fraction
    • None

    Description

      In class o.a.c.numbers.fraction.ContinuedFraction, method evaluate is declared as

      public double evaluate(double x, double epsilon, int maxIterations)
      

      Calling

      cf.evaluate(x, eps, 1)
      

      will raise an exception:

      org.apache.commons.numbers.fraction.FractionException: maximal count (1) exceeded
      

      At first sight, the check

      if (n >= maxIterations) {
      

      should rather be

      if (n > maxIterations) {
      

      However, it would also seem that the loop counter is wrong:

      while (n < maxIterations) {
      

      since setting maxIterations to 1 will in effect execute zero iteration...

      Attachments

        Activity

          People

            erans Gilles Sadowski
            erans Gilles Sadowski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: