Does Python have "not a number" floating point values?

Huaiyu Zhu hzhu at localhost.localdomain
Tue Jul 18 13:31:12 EDT 2000


On 18 Jul 2000 00:50:01 GMT, Warren B. Focke
<moron at Glue.umd.edu.bbs@openbazaar.net> wrote: 
>
>However, according to a recent post, the OpenVMS port of python uses
>VAX-format math[1], which has less exponent range than IEEE.  I think
>that that expression for Inf will not parse there.  I don't even know
>if VAXen have Inf or NaN.
>
>Warren Focke
>
>[1] http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=640022415&fmt=text

Here's my notes on this issue.  I'd like to collect more reports.

According to discussions on comp.lang.python, there is no universal way to
treat NaN, but the following codes work on Windows (NT and 98), Solaris (2.7
with gcc) and Linux (RH6.1 with egcs).

It core dumps on Tru64 Unix on Compaq Alpha [Solution: When using DEC
(Compaq) compiler to build Python try using -ieee switch].

Supposedly it should work on any machine using IEEE arithmetics.

An alternative that sometimes works is
NaN = math.exp(1000) / math.exp(1000)

-- 
Huaiyu Zhu                       hzhu at users.sourceforge.net
Matrix for Python Project        http://MatPy.sourceforge.net 



More information about the Python-list mailing list