Making signaling nans signal?

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

 



Hi,

If I understand correctly, signaling nans (as opposed to quiet nans)
should raise some sort of exception. I've searched quite a bit, and
couldn't find a way to do this.

In other words, consider the following c++ code:

================================================
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	double dqnan, dsnan;
	double t;
	
	cout << "has quiet nan: " <<
std::numeric_limits<double>::has_quiet_NaN << endl;
	cout << "has signaling nan: " <<
std::numeric_limits<double>::has_signaling_NaN << endl;
			
	dqnan = std::numeric_limits<double>::quiet_NaN();
	dsnan = std::numeric_limits<double>::signaling_NaN();
	
	t = dqnan + 1;
	
	cout << t << endl;
	
	t = dsnan + 1;
	
	cout << t << endl;
	
	return 0;
}

==========================================
I compile with no special flags: g++ t.cpp

The output is:

has quiet nan: 1
has signaling nan: 1
nan
nan

(and there is no exception)

How do I catch the "signal" of the "t = dsnan + 1;" operation? Also,
is there a way to check what kind of nan a variable is holding?

Thanks,

Abu Yoav

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux