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

josef.pktd@gmai... josef.pktd@gmai...
Tue Sep 29 18:17:16 CDT 2009


On Tue, Sep 29, 2009 at 6:48 PM, Christopher Barker
<Chris.Barker@noaa.gov> wrote:
>>> 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..
>

WindowsXP:

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
>>> struct.pack('>d', -0.0)
'\x80\x00\x00\x00\x00\x00\x00\x00'
>>> struct.pack('<d', -0.0)
'\x00\x00\x00\x00\x00\x00\x00\x80'

Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
>>> 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'

whatever that means,

Josef

> -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@noaa.gov
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list