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


fesetenv

You can use the fesetenv function to restore the floating-point environment.

void fesetenv (const fenv_t *envp);
envp
A pointer to a word containing the value to which the environment should be set.
DESCRIPTION
The fesetenv function sets the floating-point environment to the value pointed to by its argument envp. The value of envp must come from a call to either fegetenv or feholdexcept, or it may be the constant FE_DFL_ENV, which specifies the default environment. In the default environment, all exception flags are clear and the rounding direction is set to the default.

EXAMPLES
double_t func (double_t x, double_t y)
{
   fenv_t *env;

   fesetenv(FE_DFL_ENV);      /* clear environment */

   x = x + y;        /* floating-point op; may raise exceptions */
   fegetenv(env);    /* save state of env after add */

   y = y * x;        /* floating-point op; may raise exceptions */
   fesetenv(env);    /* ignore environmental changes by
                        multiplication operator */
   .
   .
   .
}

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996