octave-maintainers
[Top][All Lists]
Advanced

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

Re: isnan in fortran


From: Mike Miller
Subject: Re: isnan in fortran
Date: Wed, 11 Apr 2012 07:46:40 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Apr 11, 2012 at 07:24:18AM -0400, John W. Eaton wrote:
> On 11-Apr-2012, John W. Eaton wrote:
> 
> | On 11-Apr-2012, c. wrote:
> | 
> | | 
> | | On 10 Apr 2012, at 19:00, address@hidden wrote:
> | | 
> | | > I think it would be better to rename the files that need this
> | | > treatment to FILE.in.f and then use sed to do the transformation to
> | | > generate FILE.f in the build tree.
> | | > 
> | | > jwe
> | | 
> | | I am preparing a patch to do that.
> | 
> | After giving it some more thought, it might be better in this specific
> | case to have a configure test that checks whether isnan is available
> | in Fortran and if not, adds misc/isnan.f to the list of functions to
> | compile.  The misc/isnan.f function could be
> | 
> |       logical function isnan (x)
> |       double precision x
> |       if (x != x)
> |         isnan = .false.
> |       else
> |         isnan = .true.
> |       endif
> |       return
> |       end
> 
> Uh, except that I have the test and some syntax wrong.  How about
> 
>        logical function isnan (x)
>        double precision x
>        isnan = x .ne. x
>        return
>        end

That would be a lot clearer.  So is a single-precision NaN guaranteed to
cast to a double-precision NaN value?  Or would we need isnan and
disnan?

      logical function isnan(x)
      isnan = x .ne. x
      return
      end

      logical function disnan(x)
      double precision x
      isnan = x .ne. x
      return
      end

Both erfc and derfc will need type declarations for "logical isnan" to
call this function.  Will that break the builtin isnan if the compiler
does provide it?
-- 
mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]