More about SIGFPE can be found e.g. here:
http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?sigfpe+3
(unfortunately it doesn't tell from which unix version the manpage is taken from)
A short excerpt:
The signal SIGFPE may be raised by the floating-point accelerator upon five different conditions (overflow, underflow, divide-by-zero, inexact result, invalid operand), but usually these conditions are masked and instead of an exception a default value is used as the result of the operation.
In addition, the SIGFPE can be generated by several integer arithmetic instructions (seems nobody wanted to spend another different signal for this?), some of which are usually not masked and cause the FPE, the most common is the division by zero, I guess.
How to handle it?:
There is the possibility to have your own function called whenever a SIGFPE is generated, but for solving problems on this site, in my opinion, there is no need to do this (since the program should not generate them at all).
Example C++ source / output (the result depends on which conditions are masked on the system):
Code: Select all
double f = 1.0e1000, g = acos(2);
cout << f << endl;
cout << g << endl;
cout << 1.0 / 0.0 << endl;
cout << 0.0 / 0.0 << endl;
cout << 1 / 0 << endl;
inf
nan
inf
nan
Floating point exception