fetestexcept.3m (2010 09)

f
fetestexcept(3M) fetestexcept(3M)
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 floating-point exception
flags are currently set. The excepts argument specifies the floating-point 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 floating-point exceptions.
USAGE
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>.
For HP Integrity servers, specify
+Ofenvaccess
on the compiler command line or place the call to this
function under the effect of an affirmative FENV_ACCESS pragma:
#pragma STDC FENV_ACCESS ON
If the FENV_ACCESS pragma is placed outside of any top-level declarations in a file, the pragma will
apply to all declarations in the compilation following the pragma until another FENV_ACCESS pragma
is encountered or until the end of the file is reached.
If the
FENV_ACCESS pragma is placed at the beginning of a block (compound statement), the pragma
will apply until another FENV_ACCESS pragma is encountered or until the end of the block is reached.
For PA-RISC, you might need to use the
+Onomoveflops compiler option in order to prevent optimiza-
tions that can undermine the specified behavior of this function.
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 for HP Integrity servers at the following site:
http://www.hp.com/go/fp
.
RETURN VALUE
The
fetestexcept() function returns the bitwise OR of the exception macros corresponding to the
currently set floating-point exceptions included in excepts .
ERRORS
No errors are defined.
EXAMPLES
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();
SEE ALSO
feclearexcept(3M), fegetexceptflag(3M), fegettrapenable(3M), feraiseexcept(3M), fesetexceptflag(3M),
fesettrapenable(3M), fenv(5).
STANDARDS CONFORMANCE
fetestexcept() : ISO/IEC C99 (including Annex F, "IEC 60559 floating-point arithmetic")
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)