Well, this is messy, and nearly unreadable, but it should work and is pure python(and I think even be endian-independent).<br><br>struct.unpack('b',struct.pack('>d', X)[0])[0] >= 0<br>(where X is the variable you want to test) <br>
<br>In [54]: struct.unpack('b',struct.pack('>d',0.0)[0])[0] >= 0<br>Out[54]: True<br><br>In [55]: struct.unpack('b',struct.pack('>d',-0.0)[0])[0] >= 0<br>Out[55]: False<br><br>In [56]: struct.unpack('b',struct.pack('>d',-0.0000001)[0])[0] >= 0<br>
Out[56]: False<br><br>In [57]: struct.unpack('b',struct.pack('>d',0.0000001)[0])[0] >= 0<br>Out[57]: True<br><br>In [58]: struct.unpack('b',struct.pack('>d',3999564.8763)[0])[0] >= 0<br>
Out[58]: True<br><br>In [59]: struct.unpack('b',struct.pack('>d',-3999564.8763)[0])[0] >= 0<br>Out[59]: False<br><br>Hope that helps, anyway<br>-Joe<br><br><div class="gmail_quote">On Tue, Sep 29, 2009 at 12:04 PM, Christopher Barker <span dir="ltr"><<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">Pauli Virtanen wrote:<br>
> Tue, 29 Sep 2009 09:53:40 -0700, Christopher Barker wrote:<br>
> [clip]<br>
>> How can I identify -0.0?<br>
><br>
> signbit<br>
><br>
<br>
</div>perfect for numpy, but at this point I don't have a numpy dependency<br>
(very unusual for my code!). Anyone know a pure-python way to get it?<br>
<br>
It seems I should be able to do something like:<br>
<br>
struct.pack("d",-3.4)[0] & Something<br>
<br>
but I'm not sure what "Something" is, and it would be endian-dependent,<br>
wouldn't it?<br>
<div class="im"><br>
thanks,<br>
-Chris<br>
<br>
<br>
--<br>
Christopher Barker, Ph.D.<br>
Oceanographer<br>
<br>
Emergency Response Division<br>
NOAA/NOS/OR&R            (206) 526-6959   voice<br>
7600 Sand Point Way NE   (206) 526-6329   fax<br>
Seattle, WA  98115       (206) 526-6317   main reception<br>
<br>
<a href="mailto:Chris.Barker@noaa.gov">Chris.Barker@noaa.gov</a><br>
_______________________________________________<br>
</div><div><div></div><div class="h5">NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br>