On Feb 10, 3:29 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > platform does". Except it doesn't in cases like this. All my > platforms do exactly what I want for division by zero: they > generate a properly signed INF. Python chooses to override > that (IMO correct) platform behavior with something surprising. > Python doesn't generate exceptions for other floating point > "events" -- why the inconsistency with divide by zero?
But not everyone wants 1./0. to produce an infinity; some people would prefer an exception. Python does try to generate exceptions for floating-point events at least some of the time---e.g. generating ValueErrors for sqrt(-1.) and log(-1.) and OverflowError for exp(large_number). I agree that the current situation is not ideal. I think the ideal would be to have a floating-point environment much like Decimal's, where the user has control over whether floating-point exceptions are trapped (producing Python exceptions) or not (producing infinities and nans). The main difficulty is in writing reliable ANSI C that can do this across platforms. It's probably not impossible, but it is a lot of work. -- http://mail.python.org/mailman/listinfo/python-list