Important: The information in this document is obsolete and should not be used for new development.
feholdexcept
You can use thefeholdexceptfunction to save the current floating-point environment and then clear all exception flags.
int feholdexcept (fenv_t *envp);
envp- A pointer to an environment word where the environment should be saved.
DESCRIPTION
Thefeholdexceptfunction stores the current environment in the argumentenvpand clears the floating-point exception flags. Note that this function does not affect the rounding direction. It is the same as performing the following two calls:
fegetenv(envp); feclearexcept(FE_ALL_EXCEPT);Callfeholdexceptat the beginning of a function so that the function can start with all exceptions cleared but not change the caller's environment. Usefeupdateenvto restore the caller's environment at the end of the function. Thefeupdateenvfunction keeps any exceptions raised by the current function set while restoring the rest of the caller's environment. Thus, usingfeholdexceptandfeupdateenvtogether preserves all raised floating-point exceptions while allowing new ones to be raised as well.EXAMPLES
void subroutine(void) { fenv_t *e; /* local storage for environment */ feholdexcept(e); /* save caller's environment and clear exceptions */ /* subroutine's operations here */ feupdateenv(e); /* restore caller's environment */ }