Vedran Fura? wrote: > I think that this results must be the same: > > In [3]: math.atan2(-0.0,-1) > Out[3]: -3.1415926535897931 > > In [4]: math.atan2(-0,-1) > Out[4]: 3.1415926535897931 > > In [5]: -0 == -0.0 > Out[5]: True
Glimpsing at the hardware formats: >>> struct.pack("d", 0.0) '\x00\x00\x00\x00\x00\x00\x00\x00' >>> struct.pack("d", -0.0) '\x00\x00\x00\x00\x00\x00\x00\x80' >>> struct.pack("i", -0) '\x00\x00\x00\x00' >>> struct.pack("i", 0) '\x00\x00\x00\x00' -0 and +0 integers are identical while 0.0 and -0.0 floats are not. The negative sign is therefore lost before the int --> float conversion takes place. Peter -- http://mail.python.org/mailman/listinfo/python-list