December 2005
Beginner to intermediate
618 pages
20h 19m
English
feclearexcept
Clears status flags in the floating-point environment
#include <fenv.h> intfeclearexcept( intexcepts);
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.
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 ... */
}feraisexcept(), feholdexcept(), fetestexcept()
Read now
Unlock full access