Important: The information in this document is obsolete and should not be used for new development.
fetestexcept
You can use thefetestexcept
function 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
Thefetestexcept
function 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,
fetestexcept
returns a 0. If one of the
flags being tested is set,fetestexcept
returns the constant associated with that flag. If more than one flag is set,fetestexcept
returns the result of ORing their constants together. For example, if the inexact exception is set,fetestexcept
returnsFE_INEXACT
. If both the inexact and overflow exceptions flags are set,fetestexcept
returnsFE_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 */