Trapping FPE signals with C++ exceptions
I have a situation where some floating point operations are generating
underflows resulting in floating point assist traps. I can easily turn on
the the signals with feenableexcept(FE_ALL_EXCEPT) or one of the related
functions. I did notice that Steven Hatton discussed this about 2 years ago
on another list, but I did not see a Linux resolution.
Specifically, what I want to do is:
double d = <init value>;
try {
a /= 2; // divide by 2 to cause an underflow
} catch(some exception) {
// handle exception
}
One solution here is to set up a signal handler that throws an exception.
That is messy, but it will do the job.
--
Jerry Feldman
participants (1)
-
Jerry Feldman