Signed zeros: is this a bug?

jim-on-linux inq1ltd at verizon.net
Sun Mar 11 12:04:47 EDT 2007


On Sunday 11 March 2007 10:31, Mark Dickinson 
wrote:
> I get the following behaviour on Python 2.5 (OS
> X 10.4.8 on PowerPC, in case it's relevant.)
>
> >>> x, y = 0.0, -0.0
> >>> x, y
>
> (0.0, 0.0)
>
> >>> x, y = -0.0, 0.0
> >>> x, y
>
> (-0.0, -0.0)
>
> I would have expected y to be -0.0 in the first
> case, and 0.0 in the second.  Should the above
> be considered a bug, or is Python not expected
> to honour signs of zeros?  I'm working in a
> situation involving complex arithmetic where
> branch cuts, and hence signed zeros, are
> important, and it would be handy if the above
> code could be relied upon to do the right
> thing.
>
> Mark



This works for some reason 
instead of x,y =  -0.0, 0.0
clumpy but the results are right.

x = -0.0
y= 0.0
 
x,y
(-0.0, 0.0)




jim-on-linux
http:\\inqvista.com










More information about the Python-list mailing list