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

Robert Kern robert.kern@gmail....
Tue Sep 29 16:57:20 CDT 2009


On Tue, Sep 29, 2009 at 16:49, Joe Kington <jkington@wisc.edu> wrote:
> Using 'd' rather than 'f' doesn't fix the problem...
>
> Python 2.3.4 (#1, Jan  9 2007, 16:40:09)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import struct
>>>> struct.pack('d', -0.0)
> '\x00\x00\x00\x00\x00\x00\x00\x80'   <-- Correct signbit
>>>> struct.pack('>d', -0.0)
> '\x00\x00\x00\x00\x00\x00\x00\x00'   <-- No signbit. Unpacks to 0.0
>>>> struct.pack('<d', -0.0)
> '\x00\x00\x00\x00\x00\x00\x00\x00'   <-- No signbit.
>>>>
>
> In python 2.6 it works fine. -0.0 packs to
> '\x00\x00\x00\x00\x00\x00\x00\x80' or '\x80\x00...' as it should.
>
> I'm assuming it's a bug that was fixed somewhere in between?

Probably.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the NumPy-Discussion mailing list