| FECLEAREXCEPT(3) | Library Functions Manual | FECLEAREXCEPT(3) |
feclearexcept,
fegetexceptflag,
feraiseexcept,
fesetexceptflag,
fetestexcept — access
floating-point status flags
Math Library (libm, -lm)
#include <fenv.h>
int
feclearexcept(int
excepts);
int
fegetexceptflag(fexcept_t
*flagp, int
excepts);
int
feraiseexcept(int
excepts);
int
fesetexceptflag(const
fexcept_t *flagp, int
excepts);
int
fetestexcept(int
excepts);
These functions provide access to the floating-point status flags. The excepts input argument is a bitmask specifying an exception type and containing any of the values listed below.
FE_DIVBYZEROFE_INEXACTFE_INVALIDFor instance, subtraction of infinities, division of zero by zero, ordered comparison involving NaNs, and taking the square root of a negative number are all invalid operations.
FE_OVERFLOWFE_UNDERFLOWFE_DENORMALThis is available only on the floating-point implementations of amd64 and i386 processors.
Additionally, the macro FE_ALL_EXCEPT is
simply the bitwise OR of all floating-point exception macros listed
above.
The
feclearexcept()
function clears the floating-point exceptions represented by
excepts.
The
fegetexceptflag()
function stores a representation of the states of the floating-point flags
indicated by excepts in the object pointed to by
flagp.
The
feraiseexcept()
function raises floating-point exceptions represented by
excepts.
The
fesetexceptflag()
function sets the floating-point status flags indicated by
excepts to the states stored in the object pointed
to by flagp. The value of
flagp shall have been set by a previous call to
fegetexceptflag() whose second argument represented
at least those floating-point exceptions represented by
excepts. This function does not raise floating-point
exceptions, but only sets the state of the flags.
The
fetestexcept()
function determines which of a specified subset of the floating-point
exception flags are currently set. The excepts
specifies the floating-point status flags to be queried.
The feclearexcept(),
fegetexceptflag(),
feraiseexcept(), and
fesetexceptflag() functions return zero on success,
and non-zero if an error occurred. The
fetestexcept() function returns a bitmask of a
specified subset of the floating-point exception flags which are currently
set.
The feclearexcept(),
fegetexceptflag(),
feraiseexcept(),
fesetexceptflag(), and
fetestexcept() functions conform to
ISO/IEC 9899:1999
(“ISO C99”).
The return types for feclearexcept(),
fegetexceptflag(),
feraiseexcept(), and
fesetexceptflag() are int for
alignment with ISO/IEC 9899:1999
(“ISO C99”) Defect Report #202.
These functions first appeared in OpenBSD 5.0.
On some architectures, feraiseexcept()
additionally raises the “inexact” floating-point exception
whenever it raises the “overflow” or “underflow”
floating-point exception.
| June 7, 2025 | Debian |