[Numpy-discussion] making the distinction between -0.0 and 0.0..

Christopher Barker Chris.Barker at noaa.gov
Tue Sep 29 18:48:59 EDT 2009


>> I'm assuming it's a bug that was fixed somewhere in between?

It works on my 2.5, on a PPC:

In [10]: struct.pack('>d', -0.0)
Out[10]: '\x80\x00\x00\x00\x00\x00\x00\x00'

In [11]: struct.pack('<d', -0.0)
Out[11]: '\x00\x00\x00\x00\x00\x00\x00\x80'

But not on 2.3.5 on the same PPC (big endian, yes?)

Python 2.3.5 (#1, Jan 12 2009, 14:43:55)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1819)] on darwin

 >>> struct.pack('>d', -0.0)
'\x00\x00\x00\x00\x00\x00\x00\x00'
 >>> struct.pack('<d', -0.0)
'\x00\x00\x00\x00\x00\x00\x00\x00'

I wonder if this is a gcc difference, rather than a python one? 2.3.5 
was compiled with gcc3.3, and 2.5 with gcc 4.0.1.

I suppose I could test on Windows if I cared..

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list