NAME
fetestexcept() — test floating-point exceptions
SYNOPSIS
#include <fenv.h>
int fetestexcept(int excepts);
DESCRIPTION
The
fetestexcept()
function determines which of a specified subset of the exception flags
are currently set.
The
excepts
argument specifies the exception flags to be queried.
The argument can be constructed as a bitwise OR of the exception macros:
FE_INEXACT,
FE_DIVBYZERO,
FE_UNDERFLOW,
FE_OVERFLOW,
and
FE_INVALID.
FE_ALL_EXCEPT
represents all the exceptions.
The ISO/ANSI C committee has approved the
fetestexcept()
function for inclusion in the C9X draft standard.
To use this function, compile either with the default
-Ae
option or with the
-Aa
and
-D_HPUX_SOURCE
options. Make sure your program includes
<fenv.h>.
Link in the math library by specifying
-lm
on the compiler or linker command line.
For more information, see the
HP-UX Floating-Point Guide.
RETURN VALUE
The
fetestexcept()
function returns the bitwise OR of the exception macros corresponding
to the currently set exceptions included in
excepts.
ERRORS
No errors are defined.
EXAMPLE
Call
f()
if invalid is set, then
g()
if overflow is set:
#include <fenv.h>
/*...*/
int set_excepts;
/* operations that may raise exceptions */
set_excepts = fetestexcept(FE_INVALID | FE_OVERFLOW);
if (set_excepts & FE_INVALID) f();
if (set_excepts & FE_OVERFLOW) g();