This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/49336] ATAN2 values differ from those specified in documentation
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 9 Jun 2011 06:05:00 +0000
- Subject: [Bug libfortran/49336] ATAN2 values differ from those specified in documentation
- Auto-submitted: auto-generated
- References: <bug-49336-4@http.gcc.gnu.org/bugzilla/>
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.