Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28996 Discussions

Determine if a variable's value is finite?

jdchambless
Beginner
617 Views
Does anyone know of a function that will somehow tell you whether or not a variable has a finite value? I am trying to reprogram some old C code into Fortran, and I am having trouble finding a corollary for the C function "finite()".
0 Kudos
3 Replies
Steven_L_Intel1
Employee
617 Views
FP_CLASS
ISNAN
0 Kudos
TimP
Honored Contributor III
617 Views
In case your search engine is truly broken, here's another example of what you should have found:
http://objectmix.com/fortran/250300-detect-inf-nan-2.html
Or, if you don't have a browser, your Fortran textbook should describe ieee_is_finite, although it is not generally furnished with compilers without a fairly complete ieee_arithmetic module.

0 Kudos
Steven_L_Intel1
Employee
617 Views
... which ours is not - yet. I would also recommend against doing things such as x=x to detect NaNs, as the compiler may optimize that away unless you use /fp:strict.
0 Kudos
Reply