Important: The information in this document is obsolete and should not be used for new development.
fetestexcept
You can use thefetestexceptfunction to find out if one or more floating-point exceptions has occurred.
int fetestexcept (int excepts);
excepts- A mask indicating which floating-point exception flags should be tested.
DESCRIPTION
Thefetestexceptfunction tests the floating-point exception flags specified by its argument. The argument may be one of the constants in Table 8-2 on page 8-6, two or more of these constants ORed together, or the constantFE_ALL_EXCEPT.If all exception flags being tested are clear,
fetestexceptreturns a 0. If one of the
flags being tested is set,fetestexceptreturns the constant associated with that flag. If more than one flag is set,fetestexceptreturns the result of ORing their constants together. For example, if the inexact exception is set,fetestexceptreturnsFE_INEXACT. If both the inexact and overflow exceptions flags are set,fetestexceptreturnsFE_INEXACT | FE_OVERFLOW.EXAMPLES
feraiseexcept(FE_DIVBYZERO|FE_OVERFLOW); feclearexcept(FE_INEXACT|FE_UNDERFLOW|FE_INVALID); /* Now the divide-by-zero and overflow flags are 1, and the rest of the flags are 0. */ i = fetestexcept(FE_INEXACT); /* i = 0 because inexact is clear */ i = fetestexcept(FE_DIVBYZERO); /* i = FE_DIVBYZERO */ i = fetestexcept(FE_UNDERFLOW); /* i = 0 */ i = fetestexcept(FE_OVERFLOW); /* i = FE_OVERFLOW */ i = fetestexcept(FE_ALL_EXCEPT); /* i = FE_DIVBYZERO | FE_OVERFLOW */ i = fetestexcept(FE_INVALID | FE_DIVBYZERO); /* i = FE_DIVBYZERO */