Turn off ZeroDivisionError?

Grant Edwards grante at visi.com
Sun Feb 10 19:05:56 EST 2008


On 2008-02-10, Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
> Mark Dickinson <dickinsm at gmail.com> writes:


>>> platform does". 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.
>
> Special cases aren't special enough to break the rules.
>
> Most people would not want this behaviour either::
>
>     >>> 0.1
>     0.10000000000000001
>
> But the justification for this violation of surprise is
> "Python just does whatever the underlying hardware does with
> floating-point numbers". If that's the rule, it shouldn't be
> broken in the special case of division by zero.

My feelings exactly.

That's the rule that's always quoted to people asking about
various FP weirdness, but apparently the rule only applies
when/where certain people feel like it.

-- 
Grant Edwards                   grante             Yow!  YOW!! I'm in a very
                                  at               clever and adorable INSANE
                               visi.com            ASYLUM!!



More information about the Python-list mailing list