Re: Strange result with math.atan2()

2006-05-02 Thread Tim Peters
[Vedran Furač] > I think that this results must be the same: > > In [3]: math.atan2(-0.0,-1) > Out[3]: -3.1415926535897931 Whether -0.0 and 0.0 are different floats internally depends on your hardware floating-point; on most machines today, they are different floats, but _compare_ equal to each ot

Re: Strange result with math.atan2()

2006-05-02 Thread Vedran Furač
Serge Orlov wrote: >> So, you can convert -0 to 0, but you must multiply the result with sign of >> y, which is '-' (minus). > > But you miss the fact that 0 is an *integer*, not a float, and -0 > doesn't exist. Yes, you are right, I completely missed that 0 is integer in python, and I need a fl

Re: Strange result with math.atan2()

2006-05-02 Thread Serge Orlov
Vedran Furac wrote: > Ben Caradoc-Davies wrote: > > Vedran Furac 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 > > > > -0 is converted to 0, then to 0.0 for cal

Re: Strange result with math.atan2()

2006-05-02 Thread Vedran Furač
Ben Caradoc-Davies wrote: > 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 > > -0 is converted to 0, then to 0.0 for calculation, losing the sign. You > mig

Re: Strange result with math.atan2()

2006-05-02 Thread Ben Caradoc-Davies
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 -0 is converted to 0, then to 0.0 for calculation, losing the sign. You might as well write 0.0 instead of -0 The

Re: Strange result with math.atan2()

2006-05-02 Thread Peter Otten
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\x

Strange result with math.atan2()

2006-05-02 Thread Vedran Furač
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 This is python 2.4.4c0 on Debian GNU/Linux. Regards, Vedran Furač -- http://mail.python.org/mailman/lis