Name
fegetexceptflag
Synopsis
Stores the floating-point environment’s exception status flags
#include <fenv.h> intfegetexceptflag
( fexcept_t *flagp
, intexcepts
);
The fegetexceptflag()
function saves the current state of specified status flags in the
floating-point environment, which indicate specific floating-point
processing exceptions, in the object referenced by the pointer
argument. The object type that represents the floating-point status
flags, fexcept_t
, is defined in
fenv.h. Unlike the integer
argument that represents the floating-point exception status flags
in this and other functions that manipulate the floating-point
environment, the object with type fexcept_t
cannot be directly modified by
user programs.
The integer argument is a bitwise OR of the values of macros
defined in fenv.h to represent
the floating-point exception flags. The macros are listed under
feraiseexcept()
in this chapter.
fegetexceptflag()
stores the
state of those flags which correspond to the values that are set in
this mask.
The function returns 0 if successful; a nonzero return value indicates that an error occurred.
Example
/* Temporarily store the state of the FE_INEXACT, FE_UNDERFLOW
* and FE_OVERFLOW flags
*/
fexcept_t fpexcepts;
#pragma STDC FENV_ACCESS ON
/* Save state: */fegetexceptflag
( &fpexcepts, FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW ); feclearexcept( FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW ); /* ... Perform some calculations that might raise those exceptions ... */ /* ... Handle (or ignore) ...
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.