This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Making signaling nans signal?
- From: "Abu Yoav" <abuyoav at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 25 Sep 2007 16:51:31 +0200
- Subject: Making signaling nans signal?
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