Re:Floating point exceptions
Yes, that is the perfect answer!!!
What I am proud of myself is that in the weekend at my home computer I
eventually came across that technique in MSDN, as I have only MS VC++ 6.0 at
home. So experimenting the MS compiler I found out that they have written it
very stupidly: first signals of type SIGFPE do nothing by default; second if
you set your signal handler, it is invoked when division by zero occurs, but
not while using signaling Nan, so what is the "signaling" in their compiler?
Borland, as I saw today coming at work, have done brilliantly.
As I was using MSVC yesterday I even thought about writing a class
_double with overloaded arithmetical operators and operator double, all of
them checking for _isnan, I even wrote that class for myself.
Hopefully it may be not needed.
Thanks for your knowledge Greg.
Regards,
Boris
Quote
"Greg Chicares" <chica...@mindspring.com> wrote in message
news:3BF74A76.442D9ADD@mindspring.com...
Quote
> Boris Vidolov wrote:
> > Hallo to all,
> And to you, and to your sirma colleagues who have given so much help here.
> > I have this problem: I want to know when for some reason I made
operations
> > with invalid floating point numbers:
> > This is a pseudo code:
> > double dNan = #Nan;
> > double f = 10/dNan + 2; //I want floating point exception to be raised
here!
> > so what I do know is this
> > double dNan;
> > memset(&dNan, 0xff, sizeof dNan); //This is the only way I know to
> > explicitly make a double to be Nan
> > double f = 10/dNan + 2; //But nothing happens
> 0x0FFFFFFFFFFFFFFFF is a quiet NaN.
> You want a signaling NaN.
> Try this:
> double dNan = std::numeric_limits<double>::signaling_NaN();
> Here is a good reference:
> http://developer.intel.com/design/intarch/techinfo/pentium/fpu.htm#9786
> Here is a more general one:
> http://babbage.cs.qc.edu/courses/cs341/IEEE-754references.html