- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a program that sometimes generates a NaN value. I want to check for this in order to react to it, and I was trying to use the test 'if (A /= A) then' . . .
I tried this first in an interactive program that compiles as a QuickWin Application, and it worked just fine - when A = NaN the if condition evaluated to true.
But then when I switched to a batch program that compiles as a Fortran Console Application, it stopped working. No matter what the value of A, the if condition always evaluates to false.
The compiler options on the two projects should be identical, including having optimization turned off. Can anyone tell me what the difference between the two is, and why I can't use this test in the Fortran Console Application project?
I tried this first in an interactive program that compiles as a QuickWin Application, and it worked just fine - when A = NaN the if condition evaluated to true.
But then when I switched to a batch program that compiles as a Fortran Console Application, it stopped working. No matter what the value of A, the if condition always evaluates to false.
The compiler options on the two projects should be identical, including having optimization turned off. Can anyone tell me what the difference between the two is, and why I can't use this test in the Fortran Console Application project?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
According to the IEEE spec, a NaN is supposed to compare as "not equal" to everything, including another NaN. I know we've fixed some problems in this regard in more recent versions.
You want to use the ISNAN intrinsic instead.
Steve
You want to use the ISNAN intrinsic instead.
Steve

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