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

Charles R Harris charlesr.harris@gmail....
Tue Sep 29 12:50:43 CDT 2009


On Tue, Sep 29, 2009 at 10:53 AM, Christopher Barker
<Chris.Barker@noaa.gov>wrote:

> Hi folks,
>
> This isn't really a numpy question, and I'm doing this with regular old
> python, but I figure you are the folks that would know this:
>
> How do I get python to make a distinction between -0.0 and 0.0? IN this
> case, I'm starting with user input, so:
>
> In [3]: float("-0.0")
> Out[3]: -0.0
>
> so python seems to preserve the "-". But:
>
> In [12]: float("-0.0") == float("0.0")
> Out[12]: True
>
> In [13]: float("-0.0") < float("0.0")
> Out[13]: False
>
> In [14]: float("0.0") > float("-0.0")
> Out[14]: False
>
>
IIRC, the numbers compare equal in C, so looking at the signbit is about the
only thing you can do.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090929/db1255ce/attachment.html 


More information about the NumPy-Discussion mailing list