On 12/10/12 03:05, Stephen J. Turnbull wrote:
Steven D'Aprano writes:
I would gladly give up a small amount of speed for better control over floats, such as whether 1/0.0 raised an exception or returned infinity.
Isn't that what the fpectl module is supposed to buy, albeit much less pleasantly than Decimal contexts do?
I can't test it, because I don't have that module installed, but I would think not. Reading the docs: http://docs.python.org/library/fpectl.html I would say that fpectl exists to turn on floating point exceptions where Python currently returns an inf or NaN, not to turn on special values where Python currently raises an exception, e.g. 1/0.0. Because it depends on a build-time option, using it is even less convenient that most other non-standard libraries. It only has a single exception type for any of Division by Zero, Overflow and Invalid, and doesn't appear to trap Underflow or Inexact at all. It's not just less pleasant than Decimal contexts, but much less powerful as well. -- Steven