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 / Controlling the Exception Flags


fetestexcept

You can use the fetestexcept 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
The fetestexcept 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 constant FE_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 returns FE_INEXACT. If both the inexact and overflow exceptions flags are set, fetestexcept returns FE_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 */

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996