Name

feclearexcept

Synopsis

Clears status flags in the floating-point environment

#include <fenv.h>
intfeclearexcept( 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 ONfeclearexcept( 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()

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.