Raises floating-point exceptions #include <fenv.h> int feraiseexcept ( int excepts ); The feraiseexcept( ) function raises the floating-point exceptions represented by its argument. Unlike the fesetexceptflag( ) function, feraiseexcept( ) invokes any traps that have been enabled for the given exceptions. The argument is a bitwise OR of the values of the following macros, defined in fenv.h to represent the floating-point exception flags:
Each of these macros is defined if and only if the system supports the corresponding floating-point exception. Furthermore, the macro FE_ALL_EXCEPT is the bitwise OR of all of the macros that are supported. If feraiseexcept( ) raises the FE_INEXACT exception in conjunction with FE_UNDERFLOW or FE_OVERFLOW, then the underflow or overflow exception is raised first. Otherwise, multiple exceptions are raised in an unspecified order. The function returns 0 if successful; a nonzero return value indicates that an error occurred. ExampleAlthough user programs rarely need to raise a floating-point exception by artificial means, the following example illustrates how to do so: int result, except_set, except_test; #pragma STDC FENV_ACCESS ON feclearexcept (FE_ALL_EXCEPT); except_set = FE_OVERFLOW; result = feraiseexcept( except_set ); if ( result != 0 ) { printf( "feraisexcept( ) failed (%d)\n", result ); exit( result ); } except_test = fetestexcept( except_set ); if ( except_test != except_set ) printf( "Tried to raise flags %X, but only raised %flags X.\n", except_set, except_test ); See Alsofeclearexcept( ), feholdexcept( ), fetestexcept( ), fegetexceptflag( ), fesetexceptflag( ) |