http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49336

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |documentation
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-06-09 
06:04:41 UTC ---
(In reply to comment #0)
> the value returned by  ATAN2(-0d0, -1d0)  is  -pi  (not +pi).

The result matches POSIX:
       If y is ±0 and x is < 0, ±pi shall be returned.
       If y is ±0 and x is > 0, ±0 shall be returned.

Thus, from POSIX I would expect the result one obtains with gfortran.

Looking at IEEE 754:2008, one finds (9.2.1 Special values):
"atan2 (y, x) [...] atan2(±0, x) is ±π for x < 0"

>From the Steve's quote of the Fortran 2003 standard (comment 1) one sees that
gfortran's result is also in line with Fortran 2003.


> The documentation for ATAN2(Y,X) says:
> "If Y is zero, then the return value is zero if X is positive and pi if X is
> negative."

We should indeed update http://gcc.gnu.org/onlinedocs/gfortran/ATAN2.html -
thus, I have marked it now as documentation bug.


ahn567: Do you rely on atan (+/-0, x< 0) returning PI instead of -PI? If it is
really needed, on could add a special handling for -fno-signed-zeros. However,
that would be slower - and other compilers also follow IEEE/POSIX/F2003 - even
if they do not print signed zeros by default. Hence, I would prefer to just
update the gfortran documentation.

Reply via email to