(j3.2006) Signaling NaN
Bill Long
longb
Fri Mar 11 12:19:23 EST 2011
The standard does specify some of this, and other parts are "processor
dependent".
For this example program:
> cat ieee_nan.f90
program ieee_test_nan
use, intrinsic :: ieee_arithmetic
implicit none
real(4) :: r, s
real(8) :: x, y
r = ieee_value(r,ieee_signaling_nan)
s = ieee_value(s,ieee_quiet_nan)
x = ieee_value(x,ieee_signaling_nan)
y = ieee_value(y,ieee_quiet_nan)
write (*,*) "snan, 32-bit prints as: ", r
write (*,*) "qnan, 32-bit prints as: ", s
write (*,*) "snan, 64-bit prints as: ", x
write (*,*) "qnan, 64-bit prints as: ", y
end
we print:
> ftn ieee_nan.f90
> aprun -n1 ./a.out
snan, 32-bit prints as: NAN
qnan, 32-bit prints as: NAN
snan, 64-bit prints as: NAN
qnan, 64-bit prints as: NAN
>
Note that the standard (inconsistently) requires that on INPUT, the text
is expected to be "NAN" and on output it is "NaN". We print NAN on
output so is consistent with input expectations.
From the standard, for INPUT:
...an optional sign, followed by the string ?NAN?, optionally followed
by zero or more alphanumeric characters enclosed in parentheses,...
The NaN value is a quiet NaN if the only nonblank characters in the
field are ?NAN? or ?NAN()?; otherwise, the NaN value is processor
dependent. The interpretation of a sign in a NaN input field is
processor dependent.
For OUTPUT:
For an internal value that is an IEEE NaN, the output field consists of
blanks, if necessary, followed by the letters ?NaN? and optionally
followed by one to w?5 alphanumeric processor-dependent characters
enclosed in parentheses, right justified within the field. If w is less
than 3, the field is filled with asterisks.
Cheers,
Bill
On 3/11/11 10:26 AM, Fred J. Tydeman wrote:
> Are there any Fortran implementations that support IEEE
> Signaling NaNs?
>
> If yes, what is printed for them? And how does that
> differ from what is printed for Quiet NaNs?
>
> The C committee is working on a Technical Report on
> adding support for IEEE-754-2008 to C. One of the
> items we are considering is Signaling NaNs. We would
> like to be consistent with any other work already done.
>
>
> ---
> Fred J. Tydeman Tydeman Consulting
> tydeman at tybor.com Testing, numerics, programming
> +1 (775) 358-9748 Vice-chair of PL22.11 (ANSI "C")
> Sample C99+FPCE tests: http://www.tybor.com
> Savers sleep well, investors eat well, spenders work forever.
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
More information about the J3
mailing list