Proposed standard python module: ieee754

Warnes, Gregory R gregory_r_warnes at groton.pfizer.com
Thu Mar 27 23:17:53 EST 2003


Martin <martin at v.loewis.de> writes:
> 
> I find the name of the package misleading. It sounds like it would
> provide support for IEEE 754, but it doesn't. Instead, it relies
> that the underlying hardware is IEEE 754 compliant. 

It is true that the name could be better.  Given that we have 'fpectl' and
'fpformat', perhaps a better name would be 'fpconst', indicating that it
provides tools for dealing with floating point constants.

> If it were, this module would be nearly irrelevant.

Not at all.  As it stands now, most common platforms have IEEE 754 compliant
hardware, unfortunately, the C library routines are inconsistent in how and
whether they deal with these special values.   Consider the following :

Solaris 8 - UltraSparc - Python 2.2.1 -- compiled with gcc

	>>> float(1e3000)
	Infinity
	>>> float('Inf')
	Infinity

Windows 2000 - Pentium III - ActivePython 2.2.1

	>>> float(1e3000)
	1.#INF	
	>>> float('Inf')
	Traceback (most recent call last):
	  File "<stdin>", line 1, in ?
	ValueError: invalid literal for float(): Inf

Windows 2000 + cygwin - Pentium III - Python 2.2.2

	>>> float(1e3000)
	Inf
	>>> float('Inf')
	Traceback (most recent call last):
	  File "<stdin>", line 1, in ?
	ValueError: invalid literal for float(): Inf

Mac OS/X - PowerPC G4 - Python 2.

	>>> float(1e3000)
	Inf
	>>> float('Inf')
	Traceback (most recent call last):
	  File "<stdin>", line 1, in ?
	ValueError: invalid literal for float(): Inf

As you can see, there is no consistency among C libraries, even on the same
exact OS and CPU.

-Greg


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.





More information about the Python-list mailing list