An example of a floating point overflow is:
double d = DBL_MIN / 3.0;
The corresponding implementation of IEEE 754 should set d to " subnormal ", that is, a number that is so close to zero that accuracy decreases. You will find a lot of information about Wikipedia .
Some implementations may Flush to Zero. The consequence in the above example is setting d to zero.
Inadequacy is the result of an increase in negative indicators that are not available to represent the number. Sometimes they can be avoided by βnormalizingβ the calculation, which is equivalent to computing on x 1 * 2 N x 2 * 2 N , ... instead of x 1 , x 2 , ... for N of your choice.
The disadvantage of floating point is not undefined behavior. You can, if you want, use FPU exceptions to detect it either by polling or by receiving SIGFPE. Note that "FPU exceptions" have nothing to do with C ++ exceptions except for the name.
source share