- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there anyway to use standard fortran to initialize a double precision parameter to a IEEE NaN. The following fails because the
MODULE NaN_Value USE, INTRINSIC:: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN ! DOUBLE PRECISION, PARAMETER:: NaN = IEEE_VALUE(1D0, IEEE_QUIET_NAN) ! END MODULE
Ideally, I could have a global parameter value NaN that represents the FORTRAN NaN. I do not want to use the TRANSFER function with the integer that represents a NaN because that is not CPU/Platform independent.
thanks for your help
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use
binary B'd[d...]'
octal O'd[d...]'
hex Z'd[d...]'
You will have to select the specific SNAN or QNAN value for initialization. See: https://en.wikipedia.org/wiki/NaN#Quiet_NaN for reference information as to bit patterns. Pay attention to the Encoding section at the bottom if pertinent.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See this:
IEEE_ARITHMETIC intrinsic module already includes named constants of IEEE_QUIET_NAN and IEEE_SIGNALING_NAN.
So why would you need to define new named constants?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FortranFan wrote:
See this:
https://software.intel.com/en-us/fortran-compiler-18.0-developer-guide-a...
IEEE_ARITHMETIC intrinsic module already includes named constants of IEEE_QUIET_NAN and IEEE_SIGNALING_NAN.
So why would you need to define new named constants?
Those named constants are not nan values, they are the arguments to use for procedures to characterise or generate nan values, as per the code in the original post. But those procedures cannot be used in constant expressions in F2008, hence the issue.
Those procedures are permitted in constant expressions as of F2015. In the meantime bit setting hacks are required.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page