(j3.2006) Signaling NaN

Tobias Burnus burnus
Fri Mar 11 12:36:23 EST 2011


On 03/11/2011 05:26 PM, Fred J. Tydeman wrote:
> Are there any Fortran implementations that support IEEE
> Signaling NaNs?

Yes.

> If yes, what is printed for them?  And how does that
> differ from what is printed for Quiet NaNs?

My impression what that when a NaN is signalling, it is either trapped 
which causes an abort (SIGARITH) or if it is not trapped, it is regarded 
ordinary (quiet) NaN - except that a warning might be printed at the end.


Probably more interstingly, the standard states the following. (FDIS is 
available at ftp://ftp.nag.co.uk/sc22wg5/N1801-N1850/N1830.pdf)


For output, it just has:

"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." (Fortran 2008, "10.7.2.3.2 
F editing")


[Side remark: I think I have never seen values in parentheses. (I 
vaguely remember some comp.lang.fortran posting where some other string 
than "NaN" was used, but it did not follow the allowed pattern of the 
standard.) -- I think C allows the same, but at least GLIBC does not 
seem to handle it - neither for input nor for output.]


Maybe also of interest: For input (which is case insensitive):

"The value specified by 'NAN' is an IEEE NaN; this form shall not be 
used if the processor does not support IEEE NaNs for the input variable. 
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." (same section)


The following is about printing a warning - at the program termination - 
about signalling exceptions:

"When an image is terminated by a STOP or ERROR STOP statement, its stop 
code, if any, is made available in a processor-dependent manner. If any 
exception (14) is signaling on that image, the processor shall issue a 
warning indicating which exceptions are signaling; this warning shall be 
on the unit identi
ed by the named constant ERROR UNIT (13.8.2.8)." 
(From: "8.4 STOP and ERROR STOP statements")

Tobias



More information about the J3 mailing list