NaN again - and IEEE arithmatics
Mark C Favas
mark at chem.uwa.edu.au
Sat May 13 08:56:37 EDT 2000
"Tim Peters" <tim_one at email.msn.com> writes:
>THere's nothing you can do that's guaranteed to work. Here's a way to make
>a NaN that's quite *likely* to work on any IEEE-754 platform, though:
>>>> Inf = 1e300**2
>>>> NaN = Inf - Inf
>>>> NaN
>-1.#IND
>>>> Inf
>1.#INF
>>>>
>Since that was a Windows session, that's how Microsoft happens to spell NaN
>and infinity these days.
Unfortunately, on a real <0.3 wink> operating system (Tru64 Unix on Compaq
Alpha) this code fragment produces a core dump:
Python 1.6a2 (#99, May 12 2000, 08:21:33) [C] on osf1V4
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
>>> Inf = 1e300**2
Floating exception (core dumped)
Cheers,
Mark
--
Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas
Phone - +61 9 380 3482 / \ Department of Chemistry
Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia
v Nedlands
Loc - 31.97 S, 115.81 E Western Australia 6009
More information about the Python-list
mailing list