- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm having some unexpected behaviour from NaN's when swithing to the Intel C++ compiler.
#include <math.h> int main() { // Comparing two NaNs should result in a False if (NAN == NAN) return -1; return 0; }
Comparing two NaNs should result in a False but results in a True. Any ideas what's up with this?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a more complete example:
// NaNTest.cpp : Defines the entry point for the console application.
//#include "stdafx.h"
#include <math.h>
#include <iostream>int _tmain(int argc, _TCHAR* argv[])
{
if (NAN == NAN)
std::cerr << "Bad NaN" << std::endl;
else
std::cout << "Good NaN" << std::endl;getchar();
return 0;
}
Visual Studio 2013 compiler returns "Good NaN" while Intel C++ 14 compiler returns "Bad NaN" after running the above code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just figured it out myself. The default floating point model is /fp:fast and must be set to /fp:strict or /fp:precise for NaN's to work properly.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page