[issue8692] Use divide-and-conquer for faster factorials
Mark Dickinson
report at bugs.python.org
Wed May 12 21:08:01 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
>I was planning to add a "if (dx > (double) LONG_MAX)" check. Would
> that be sufficient?
Hmm. It's subtle. On an LP64 machine, LONG_MAX will be 2**63-1, which isn't exactly representable as a double. So (double) LONG_MAX would likely be 2.0**63 exactly (depending on rounding mode, but round-half-to-even is probably a safe assumption unless someone's deliberately messing around). Then that check would fail for dx == 2.**63 exactly.
Turn it into '>=' rather than '>', and I *think* it's okay.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8692>
_______________________________________
More information about the Python-bugs-list
mailing list