Tim Peters added the comment:

Victor, happy to add comments, but only if there's sufficient interest in 
actually using this.  In the context of this issue report, it's really only 
important that Mark understands it, and he already does ;-)

For example, it starts with float `**` because that's by far the fastest way to 
get a very good approximation.  Then it switches to Decimal to perform a Newton 
step using greater-than-float precision, which is necessary to absorb rounding 
errors in intermediate steps.  Then it rounds back to float, because it has to 
- it's a "float in, float out" function.  It's for the same reason, e.g., that 
Mark's `nroot` converts floats to potentially gigantic integers for its Newton 
step(s), and my other `fractions.Fraction` function converts floats to 
potentially gigantic rationals.  "Potentially gigantic" may be necessary to 
guarantee always-correct rounding of the final result, but isn't necessary to 
guarantee < 1 ulp error in the final result.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue27761>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to