[Bug fortran/51569] New: documentation on sign intrinsic
pascal22p at parois dot net
gcc-bugzilla@gcc.gnu.org
Thu Dec 15 16:11:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51569
Bug #: 51569
Summary: documentation on sign intrinsic
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pascal22p@parois.net
The documentation of the sign intrinsic is a bit misleading when the B argument
is a signed zero. The explanation in the standard is much more clearer.
Currently it says
(http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gfortran/SIGN.html#SIGN):
"If B\ge 0 then the result is ABS(A), else it is -ABS(A)."
According to the standard -0.0 is greater than zero. Meaning that according to
the documentation I would expect:
sign(1.0,-0.0) = 1.0
which is not true.
I would replace the sentence above by what you can find in the standard:
http://j3-fortran.org/doc/2003_Committee_Draft/ISO_IEC_1539-1.pdf in page 361
(pdf page), 345 (printed page number)
Case (i): If B > 0, the value of the result is |A|.
Case (ii): If B < 0, the value of the result is -|A|.
Case (iii): If B is of type integer and B=0, the value of the result is |A|.
Case (iv): If B is of type real and is zero, then
(1) If the processor cannot distinguish between positive and negative real
zero,
the value of the result is |A|.
(2) If B is positive real zero, the value of the result is |A|.
(3) If B is negative real zero, the value of the result is -|A|.
More information about the Gcc-bugs
mailing list