Mark Dickinson added the comment:

One question:  is there a policy on what should happen for singularities and 
domain errors?  If 
not, I think it would be useful to have one.  Following the policy may not be 
achievable on all 
platforms, but it should be easy to do on major platforms, and at least we'll 
know what we're 
aiming for in general.  Maybe it already exists, and I missed it :)

For domain errors (e.g. sqrt(-1), log(-1), acosh(0)), the obvious two options 
are:
  - raise an exception (e.g. OverflowError), or
  - return a NaN

For singularities (e.g. log(0), atanh(1)), the options are basically the same:
  - raise an exception (preferably something different from OverflowError), or
  - return the IEEE-754 recommended value (usually +/-Inf)

I suspect there are use-cases for both types of behaviour here.

Of course, the *right* thing to do, in some sense, would be to have a 
thread-local floating-point 
environment that makes it possible for the user to choose whether he/she wants 
an exception or a 
special value, much like the way Decimal behaves at the moment.  But that would 
be a big change, 
almost certainly requiring a PEP and a lot of work.

A few months ago I definitely would have said that an exception should be 
raised in both cases, as 
already happens (mostly);  but since then NaNs and Infinities have acquired 
greater legitimacy 
within Python.

Tim, if you're listening:  any words of wisdom?

Should I ask this on python-dev?

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1640>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to