public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51569] New: documentation on sign intrinsic
@ 2011-12-15 16:11 pascal22p at parois dot net
  2011-12-15 16:29 ` [Bug fortran/51569] " pascal22p at parois dot net
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pascal22p at parois dot net @ 2011-12-15 16:11 UTC (permalink / raw)
  To: gcc-bugs

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|.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51569] documentation on sign intrinsic
  2011-12-15 16:11 [Bug fortran/51569] New: documentation on sign intrinsic pascal22p at parois dot net
@ 2011-12-15 16:29 ` pascal22p at parois dot net
  2011-12-29  6:07 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pascal22p at parois dot net @ 2011-12-15 16:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Pascal <pascal22p at parois dot net> 2011-12-15 16:28:11 UTC ---
(In reply to comment #0)
> 
> According to the standard -0.0 is greater than zero. 

Sorry, I am also confusing things by saying this.
please read instead "-0.0>=0.0 return True"


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51569] documentation on sign intrinsic
  2011-12-15 16:11 [Bug fortran/51569] New: documentation on sign intrinsic pascal22p at parois dot net
  2011-12-15 16:29 ` [Bug fortran/51569] " pascal22p at parois dot net
@ 2011-12-29  6:07 ` pinskia at gcc dot gnu.org
  2011-12-29 17:59 ` kargl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-29  6:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-12-29 06:02:53 UTC ---
-0.0 does not exist in Fortran except when using the IEEE module IIRC.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51569] documentation on sign intrinsic
  2011-12-15 16:11 [Bug fortran/51569] New: documentation on sign intrinsic pascal22p at parois dot net
  2011-12-15 16:29 ` [Bug fortran/51569] " pascal22p at parois dot net
  2011-12-29  6:07 ` pinskia at gcc dot gnu.org
@ 2011-12-29 17:59 ` kargl at gcc dot gnu.org
  2012-01-15 18:06 ` kargl at gcc dot gnu.org
  2012-01-15 18:48 ` kargl at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2011-12-29 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #3 from kargl at gcc dot gnu.org 2011-12-29 17:55:09 UTC ---
(In reply to comment #2)
> -0.0 does not exist in Fortran except when using the IEEE module IIRC.

Nope.  The IEEE module is not necessary.  Negative zero falls into
the wonderful world of processor-dependent behavior.

Fortran 2003, 1.6.1:

(3) If the processor can distinguish between positive and negative
    real zero, this standard requires different returned values for
    ATAN2(Y,X) when X < 0 and Y is negative real zero and for LOG(X)
    and SQRT(X) when X is complex with REAL(X) < 0 and negative zero
    imaginary part.

Fortran 2003, 1.6.3:

(5) If the processor can distinguish between positive and negative
    real zero, the behavior of the SIGN intrinsic function when the
    second argument is negative real zero is changed by this
    standard.

Fortran 2003, 4.4.2:

The real type includes a zero value.  Processors that distinguish
between positive and negative zeros shall treat them as equivalent
    (1)  in all relational operations,
    (2)  as actual arguments to intrinsic procedures other than
         those for which it is explicitly specified that negative
         zero is distinguished, and
    (3)  as the scalar-numeric-expr in an arithmetic IF.

I've read gfortan's description for SIGN(), and IMHO, there is
nothing to change.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51569] documentation on sign intrinsic
  2011-12-15 16:11 [Bug fortran/51569] New: documentation on sign intrinsic pascal22p at parois dot net
                   ` (2 preceding siblings ...)
  2011-12-29 17:59 ` kargl at gcc dot gnu.org
@ 2012-01-15 18:06 ` kargl at gcc dot gnu.org
  2012-01-15 18:48 ` kargl at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2012-01-15 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #4 from kargl at gcc dot gnu.org 2012-01-15 18:03:05 UTC ---
(In reply to comment #0)
> 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:

The documentation as written is fine.  It seems that you
are reading 'B \ge 0' in gfortran's documentation as a 
Fortran expression instead of as a mathematical expression.
>From the point of view of mathematics if B = -0., then
B is less than 0.; otherwise, the foundations of calculus
would not apply when taking a limit of a function at 0.
Closing as WONTFIX.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51569] documentation on sign intrinsic
  2011-12-15 16:11 [Bug fortran/51569] New: documentation on sign intrinsic pascal22p at parois dot net
                   ` (3 preceding siblings ...)
  2012-01-15 18:06 ` kargl at gcc dot gnu.org
@ 2012-01-15 18:48 ` kargl at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2012-01-15 18:48 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WONTFIX

--- Comment #5 from kargl at gcc dot gnu.org 2012-01-15 18:04:04 UTC ---
Update the RESOLVED tag from FIXED to WONTFIX.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-15 18:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-15 16:11 [Bug fortran/51569] New: documentation on sign intrinsic pascal22p at parois dot net
2011-12-15 16:29 ` [Bug fortran/51569] " pascal22p at parois dot net
2011-12-29  6:07 ` pinskia at gcc dot gnu.org
2011-12-29 17:59 ` kargl at gcc dot gnu.org
2012-01-15 18:06 ` kargl at gcc dot gnu.org
2012-01-15 18:48 ` kargl at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).