[J3] defining a parameter to be signaling NaN?
Van Snyder
Van.Snyder at jpl.nasa.gov
Tue May 22 19:38:39 EDT 2018
On Tue, 2018-05-22 at 20:35 +0000, Bill Long via J3 wrote:
> > On May 22, 2018, at 3:03 PM, Robert Corbett via J3
> <j3 at mailman.j3-fortran.org> wrote:
> >
> > I cannot think of a portable way to initialize variables to
> signaling NaNs, even for processors that implement the highest level
> of IEEE support defined by the standard. As Bill noted, REAL with an
> appropriate BOZ constant as the first argument might work, but it is
> not portable. TRANSFER is another possibility.
> >
> > The standard permits the expression
> >
> > IEEE_VALUE(0.0,IEEE_SIGNALING_NAN)
> >
> > to produce a quiet NaN. IIRC, this behavior was added as a result
> of an interpretation.
>
> The standard does say that, but there is a NOTE just following that
> says:
>
> "If the expr in an assignment statement is a reference to the
> IEEE_VALUE function that returns a signaling NaN and the variable is
> of the same type and kind as the function result, it is recommended
> that the signaling NaN be preserved."
>
> IEEE_VALUE is pretty useless for a processor that does not follow that
> recommendation. I assume “assignment statement” would include an
> initialization as well, if this reference is allowed as the constant
> expression in an initialization.
IIRC, The reason for the interp and the recommendation was that
referencing a signaling NaN ought to cause a trap. That makes a
function that produces one pretty much useless. The purpose of
initializing to a signaling NaN is to get a trap if your code doesn't
initialize the variable. This is useful because the ability of
processors to detect references to undefined variables varies greatly.
This wouldn't apply to a named constant value. Presumably, a reference
to a named constant with a signaling NaN value (as opposed to using one
as an initializer) would also cause a trap.
More information about the J3
mailing list