On Tue, Nov 24, 2020 at 09:01:27AM +1100, Steven D'Aprano wrote:
> On Mon, Nov 23, 2020 at 04:26:20PM -0500, Wes Turner wrote:
> 
> > Is there a different IEEE spec or CAS that distinguishes between 1/x and
> > 2/x where x=0?
> 
> No. x/0.0 would either signal an error (in Python terms: raise an 
> exception) or return a NAN. The specific NAN it might return is not set 
> by the IEEE-754 standard.

Correction (as noted in my next post), it actually returns a signed 
infinity.

It *ought to* return a NAN, unless we interpret the denominator as an 
underflowed non-zero quantity rather than precisely and exactly zero, 
which seems to be what the standard does.

In any case, there's only a single pair of infinities, so you can't 
distinguish between two expressions which return infinities with the 
same sign. You can't distinguish between cases that "overflow to 
infinity" from "actual mathematical infinity" (if such a thing existed 
in the real numbers) either.

So IEEE-754 should be considered as trying to make practical, pragmatic 
decisions rather than aiming for mathematical purity.


-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BYU26MU4O7C725QKILFPR6KKUSEDLAVV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to