[J3] defining a parameter to be signaling NaN?
Bill Long
longb at cray.com
Tue May 22 11:48:23 EDT 2018
> On May 22, 2018, at 7:39 AM, Clune, Thomas L. (GSFC-6101) via J3 <j3 at mailman.j3-fortran.org> wrote:
>
> A colleague was asking me about why the following code is not conforming
> (assuming the appropriate USE statements):
>
>
>
> real, parameter :: my_snan = ieee_value(0.0,ieee_signaling_nan)
This seems to work:
real :: my_snan
my_snan = ieee_value(0.0,ieee_signaling_nan)
>
>
>
>
> The standard does note that the types and procedures in the intrinsic IEEE
> modules are not themselves intrinsic, and thus the expression is not suitable for defining a PARAMETER.
>
Transformational functions from IEEE_ARITHMETIC are allowed:
• a reference to a transformational function from the intrinsic module IEEE_ARITHMETIC or IEEE_EXCEPTIONS, where each argument is a constant expression,
>
But IEEE_VALUE is elemental.
In practice, I don’t see a problem with allowing IEEE_VALUE in a constant expression. Maybe Bob (aka Dr. IEEE) has a reason that’s not obvious to me.
If, for some reason, a named constant is urgently needed (as opposed to a module variable with the PROTECTED attribute), then you could try
real,parameter :: my_snan = real(Z"7F800001”)
which assumes a particular representation for an SNAN.
Why the interest in a named constant for a signaling NaN? Comparing another value for equal to that constant is not useful.
Cheers,
Bill
>
> First, is this explanation correct?
>
>
> Second, presuming that the explanation is correct, was this our intent?
> Is there a reasonably way to set a parameter to a signaling nan value, or do we need to propagate the longer expression to various parts of our code? Or could additional intrinsics be defined such as IEEE_SIGNALING_NAN_REAL32?
>
>
>
> Thanks,
>
>
> - Tom
>
>
Bill Long longb at cray.com
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
More information about the J3
mailing list