Previous Page
Next Page

feclearexcept

Clears status flags in the floating-point environment

#include <fenv.h>
int feclearexcept ( int excepts  );

The feclearexcept( ) function clears the floating-point exceptions specified by its argument. The value of the argument is the bitwise OR of one or more of the integer constant macros described under feraiseexcept( ) in this chapter.

The function returns 0 if successful; a nonzero return value indicates that an error occurred.

Example

double x, y, result;
int exceptions;

#pragma STDC FENV_ACCESS ON
feclearexcept( FE_ALL_EXCEPT );
result = somefunction( x, y );    // This function may raise exceptions!
exceptions = fetestexcept( FE_INEXACT | FE_UNDERFLOW );

if ( exceptions & FE_UNDERFLOW )
{
  /* ... handle the underflow ... */
}
else if ( exceptions & FE_INEXACT )
{
  /* ... handle the inexact result ... */
}

See Also

feraisexcept( ), feholdexcept( ), fetestexcept( )


Previous Page
Next Page