How to represent the infinite ?

Tim Peters tim.one at comcast.net
Fri Jun 21 18:25:54 EDT 2002


[Huaiyu Zhu]
> ...
> Now I'm confused.  I thought from previous discussions that you
> intended to disable inf and nan until full ieee floating point
> compliance is implemented in Python.

I intended that x**y act the same as math.pow(x, y).

> And I infered that that's in order to make Windows work.

It has nothing to do with Windows specifically; Python's 754 behavior "is
random" on all platforms, in platform-specific ways, because Python is
implemented in C, platform C 754 behavior "is (still) random", and the only
code ever contributed to address this sorry state of affairs is the fpectl
module (whose purpose is in a direction opposite the one you favor).

> Since it could be made to work on Linux, I simply commented out
> the checking in pyport.h.  Voila, instant ieee compliance!

You happened to get one particular 754 behavior you like; full IEEE
compliance is a large and difficult task; subset compliance is worse than
none (if we're to believe Kahan's virulent rants about Java <wink>).

> Your example appears to show that Windows can also live with nan and inf.

Virtually all platforms can, given enough platform-specific support code,
almost none of which Python has.

> So my question is, are there any significant platforms out there
> that still really need such checkings which make nan and inf almost
> useless?

If Python were 100% 754-conforming, Guido and I would still favor enabling
exceptions on overflow, divide-by-zero, and invalid operation, by default.
As things are, you've got no choice at all, unless you want such exceptions
enabled and are on a platform where the fpectl module happens to work.






More information about the Python-list mailing list