C <fenv.h> - FE_UNDERFLOW
The FE_UNDERFLOW macro expands to a value of type integer constant expression that is distinct powers of 2, which uniquely identifies the floating-point exception raised on underflow range errors.
Underflow range errors occur when the result of an operation cannot be represented as a value of its return type because its magnitude is too small (with either positive or negative sign). Operations that overflow return an unspecified value whose magnitude is no greater than the smallest normalized positive number. Whether an operation raises this exception is implementation-defined.
Definition in the <fenv.h> header file is:
#define FE_UNDERFLOW /*implementation defined power of 2*/
The details about all floating-point exception macros are listed below:
Macros | Description |
---|---|
FE_DIVBYZERO | Pole error exception occurred in an earlier floating-point operation. |
FE_INEXACT | Inexact result exception occurred in an earlier floating-point operation (rounding was necessary to store the result). |
FE_INVALID | Invalid argument exception occurred (domain error occurred) in an earlier floating-point operation. |
FE_OVERFLOW | Overflow range error exception occurred in an earlier floating-point operation (result was too large to be representable). |
FE_UNDERFLOW | Underflow range error exception occurred in an earlier floating-point operation (result was subnormal with a loss of precision). |
FE_ALL_EXCEPT | Bitwise OR of all supported floating-point exceptions. |
Certain library implementations may define additional macro constants in <fenv.h> to identify additional floating-point exceptions (with their corresponding macros also beginning with FE_).
See math_errhandling for more details.
Example:
The example below shows the usage of FE_UNDERFLOW macro.
#include <stdio.h> #include <fenv.h> #include <float.h> #include <math.h> int main (){ printf("nextafter(DBL_MIN/pow(2.0,52),0.0) = %f\n", nextafter(DBL_MIN/pow(2.0,52),0.0)); if(fetestexcept(FE_UNDERFLOW)) printf("Domain error is reported.\n"); else printf("Domain error is not reported.\n"); return 0; }
The output of the above code will be:
nextafter(DBL_MIN/pow(2.0,52),0.0) = 0.000000 Domain error is reported.
❮ C <fenv.h> Library