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

Robert Kern robert.kern@gmail....
Tue Sep 29 16:39:43 CDT 2009


On Tue, Sep 29, 2009 at 16:37, Joe Kington <jkington@wisc.edu> wrote:
> I know it's a bit pointless profiling these, but just so I can avoid doing
> real work for a bit...
>
> In [1]: import sys, struct, math
>
> In [2]: def comp_struct(x):
>    ...:     # Get the first or last byte, depending on endianness
>    ...:     # (using '>f' or '<f' loses the signbit for -0.0 in older
> python's)

Did you try 'd'? I wonder if the extra conversion step from a C double
to a C float is causing this issue.

-- 
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