Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 8 - Environmental Control Functions / Accessing the Floating-Point Environment


feholdexcept

You can use the feholdexcept function 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
The feholdexcept function stores the current environment in the argument envp and 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);
Call feholdexcept at the beginning of a function so that the function can start with all exceptions cleared but not change the caller's environment. Use feupdateenv to restore the caller's environment at the end of the function. The feupdateenv function keeps any exceptions raised by the current function set while restoring the rest of the caller's environment. Thus, using feholdexcept and feupdateenv together 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 */
}

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996