Returns the value for NaN.
Returns, as a scalar, a value corresponding to the IEEE 754 Standard format of floating point (ANSI/IEEE 1985) for NaN. For other floating point formats a special pattern is returned that tests .true. using the function isNaN. (Output)
X — Scalar value of the same type and precision as the desired result, NaN. This input value is used only to match the type of output. (Input)
NaN (A)
NaN returns, as a scalar, a value corresponding to the IEEE 754 Standard format of floating point (ANSI/IEEE 1985) for NaN.
The bit pattern used for single precision is transfer
(not(0),1).
For
double precision, the bit pattern for single precision is replicated by
assigning the temporary integer array
i(1:2) =
not(0),
and then using the double-precision bit pattern transfer(i,x)
for the output value.
Arrays are assigned all NaN values, using single and double-precision formats. These are tested using the logical function routine, isNaN.
use isnan_int
implicit none
! This is the equivalent of Example 1 for NaN.
integer, parameter :: n=3
real(kind(1e0)) A(n,n); real(kind(1d0)) B(n,n)
real(kind(1e0)), external :: s_NaN
real(kind(1d0)), external :: d_NaN
! Assign NaNs to both A and B:
A = s_Nan(1e0); B = d_Nan(1d0)
! Check that NaNs are noted in both A and B:
if (isNan(A) .and. isNan(B)) then
write (*,*) 'Example 1 for NaN is correct.'
end if
end
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |