How to detect NaN's

David Warren warren at atmos.washington.edu
Sat Jun 1 10:44:33 AEST 1991


In article <1991May30.204332.16506 at litwin.com> vlr at litwin.com (Vic Rice) writes:

   Xref: milton comp.unix.ultrix:6260 comp.lang.fortran:3304
   Path: milton!hayes.ims.alaska.edu!bionet!uwm.edu!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!dynsim1!litwin!vlr
   From: vlr at litwin.com (Vic Rice)
   Newsgroups: comp.unix.ultrix,comp.lang.fortran
   Date: 30 May 91 20:43:32 GMT
   Organization: Litwin Process Automation
   Lines: 9

   I have encountered a problem on a DECStation 5000 using the Mips Fortran
   compiler. Some operation I am performing is generating a NaN which then
   proceeds to propogate to other dependent variables. Since this is in
   a loop, I am not exactly sure where it starts.

   How can I test a variable for the presence of a NaN or Infinity ???
   -- 
   Dr. Victor L. Rice
   Litwin Process Automation


how about linking with this c function:

int *check_nan_(num)
/*make sure num != NaN*/
float *num;
{
    int true=1,false=0;
    if(isnan((double)num))return(&true);
    else return(&false);
}

then do

ISTAT = CHECK_NAN(RVAL)
--
David Warren 		INTERNET: warren at atmos.washington.edu
(206) 543-0945		UUCP:	  uw-beaver!atmos.washington.edu!warren
Dept of Atmospheric Sciences, AK-40
University of Washington



More information about the Comp.unix.ultrix mailing list