newLoop returns a new loop checker. Arguments: - name: name of the function being calculated (for error messages) - arg: argument to the function (for error messages) - precision: desired precision; the loop ends when consecutive estimates differ less than the desired precision.
(name string, arg *Decimal, precision uint32, maxItersPerDigit int)
| 34 | // - maxItersPerDigit: after this many iterations per digit of precision, the |
| 35 | // loop ends in error. |
| 36 | func (c *Context) newLoop(name string, arg *Decimal, precision uint32, maxItersPerDigit int) *loop { |
| 37 | return &loop{ |
| 38 | c: c, |
| 39 | name: name, |
| 40 | arg: new(Decimal).Set(arg), |
| 41 | precision: int32(precision), |
| 42 | maxIterations: 10 + uint64(maxItersPerDigit*int(precision)), |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // done reports whether the loop is done. If it does not converge |
| 47 | // after the maximum number of iterations, it returns an error. |