[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: COBOL, IEEE Std 754-2008 Signaling NaN



In the sense I believe you are talking about, no.  
 
Historically, standard COBOL has never been about floating-point arithmetic or operands.  Most implementors provided floating-point capabilities matching their particular implementation, and thus the methods and results for them were completely implementor-defined. 
 
Floating-point arithmetic and floating-point data items were introduced in the 2002 standard, and a good part of the methods and results for these were defined by the implementor, seriously limiting portability from one implementation to another.   
 
What we propose for the upcoming COBOL standard is a focus on the five "basic interchange formats", on manipulation of finite numeric values in those formats, and on the rules for arithmetic consistent with (not necessarily conforming to) the 128-bit basic binary and decimal interchange formats.  Both NaN's and infinities are treated as NON-NUMERIC, and any effort to deal with either one as a numeric sending operand results in a fatal exception condition. 
 
The proposed COBOL standard does recognize NaN's, and provisions do exist for testing for their presence in a data item, but does not, for example, "signal" their presence by putting a non-numeric character-string in a numeric receiving operand. 
 
I personally think adding functions to determine whether a NaN in a data item is signaling or quiet, and to extract the numeric value of the payload from the NaN, would be easy to add to the standard and easy for the implementor to provide, but this point came up rather late in the review process, and it may not be feasible to add such functions in the next published revision of the COBOL standard.  
 
I plan to write a proposal to add these two functions for consideration by OWG-1 and WG4 for inclusion in the next published COBOL standard   What happens to it is up to those committees. 
 
    -Chuck Stevens
 
> From: tydeman@xxxxxxxxx
> To: charles.stevens@xxxxxxxx; stds-754@xxxxxxxxxxxxxxxxx
> Date: Sun, 10 Apr 2011 13:50:32 -0700
> Subject: COBOL, IEEE Std 754-2008 Signaling NaN
>
> On Sun, 20 Mar 2011 09:50:01 -0600 Charles Stevens wrote:
> >
> >Comments? Further refinement suggestions?
>
> Will there be support for Signaling NaNs (in either binary FP
> or decimal FP)?
>
> If yes, what will be printed for them?
> What forms will be valid input to read at run time?
>
> Fortran, since at least the 2003 standard has had "support" for
> signaling NaNs, but most implementations that I have seen the
> output from, print the same string NaN for both quiet and
> signaling NaNs. The only exception is IBM that prints NaNQ
> and NaNS (which does not conform to Standard Fortran).
>
> Standard Fortran says that (case insensitive) NAN and NAN()
> are quiet NaNs, while everything else is processor dependent.
>
> C99 considered adding support for Signaling NaNs, but decided
> against. There is a group of people writing a technical report
> on adding IEEE-754-2008 to C, and part of the report is a section
> on signaling NaNs.
>
> Here is a Fortran program to see if signaling NaNs can be
> created, and to see what prints:
>
> program ieee_test_nan
>
> use, intrinsic :: ieee_arithmetic
> implicit none
> real(4) :: ss, sq,x
> real(8) :: ds, dq
> integer(4) :: iss,isq
> integer(8) :: ids,idq
> character(25) :: css, csq, cds, cdq
>
> ss = ieee_value(ss,ieee_signaling_nan)
> iss = transfer(ss,iss)
> sq = ieee_value(sq,ieee_quiet_nan)
> isq = transfer(sq,isq)
> ds = ieee_value(ds,ieee_signaling_nan)
> ids = transfer(ds,ids)
> dq = ieee_value(dq,ieee_quiet_nan)
> idq = transfer(dq,idq)
>
> write (*,"(a22,f8.3,z10.8)") "ieee_signaling_nan is ", ss,iss
> write (*,"(a22,f8.3,z10.8)") "ieee_quiet_nan is ", sq,isq
>
> if (ieee_class(ss) == ieee_signaling_nan) then
> css = " = ieee_signaling_nan"
> else
> css = "NOT ieee_signaling_nan"
> end if
>
> if (ieee_class(sq) == ieee_quiet_nan) then
> csq = " = ieee_quiet_nan"
> else
> csq = "NOT ieee_quiet_nan"
> end if
>
> if (ieee_class(ds) == ieee_signaling_nan) then
> cds = " = ieee_signaling_nan"
> else
> cds = "NOT ieee_signaling_nan"
> end if
>
> if (ieee_class(dq) == ieee_quiet_nan) then
> cdq = " = ieee_quiet_nan"
> else
> cdq = "NOT ieee_quiet_nan"
> end if
>
> write (*,*) "snan, 32-bit prints as: ", ss, " ", css
> write (*,*) "qnan, 32-bit prints as: ", sq, " ", csq
> write (*,*) "snan, 64-bit prints as: ", ds, " ", cds
> write (*,*) "qnan, 64-bit prints as: ", dq, " ", cdq
>
> end
>
> ---
> Fred J. Tydeman Tydeman Consulting
> tydeman@xxxxxxxxx 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.

754 | revision | FAQ | references | list archive