'\" t .\" @(#)feclearexcept.3m 1.4 97/06/25 SMI .TH feclearexcept 3M "06/25/97" .SH NAME feclearexcept, feraiseexcept, fetestexcept, fegetexceptflag, fesetexceptflag \- access floating point exception flags .SH SYNOPSIS .LP .B cc .RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|." .B -R/opt/SUNWspro/lib -L/opt/SUNWspro/lib -lm9x .RI "[ " "library" " \|.\|.\|. ]" .LP .B #include .LP .BI "void feclearexcept(int " excepts ); .LP .BI "void feraiseexcept(int " excepts ); .LP .BI "int fetestexcept(int " excepts ); .LP .BI "void fegetexceptflag(fexcept_t *" flagp ", int " excepts ); .LP .BI "void fesetexceptflag(const fexcept_t *" flagp ", int " excepts ); .LP .B #include .LP .BI "void feclearexcept96(int " excepts ); .LP .BI "void feraiseexcept96(int " excepts ); .LP .BI "int fetestexcept96(int " excepts ); .LP .BI "void fegetexceptflag96(fexcept_t *" flagp ", int " excepts ); .LP .BI "void fesetexceptflag96(const fexcept_t *" flagp ", int " excepts ); .SH DESCRIPTION .IX "feclearexcept function" "" "\fLfeclearexcept()\fP function" .IX "feraiseexcept function" "" "\fLferaiseexcept()\fP function" .IX "fetestexcept function" "" "\fLfetestexcept()\fP function" .IX "fegetexceptflag function" "" "\fLfegetexceptflag()\fP function" .IX "fesetexceptflag function" "" "\fLfesetexceptflag()\fP function" .IX "feclearexcept96 function" "" "\fLfeclearexcept96()\fP function" .IX "feraiseexcept96 function" "" "\fLferaiseexcept96()\fP function" .IX "fetestexcept96 function" "" "\fLfetestexcept96()\fP function" .IX "fegetexceptflag96 function" "" "\fLfegetexceptflag96()\fP function" .IX "fesetexceptflag96 function" "" "\fLfesetexceptflag96()\fP function" .LP These functions provide access to the floating point exception flags. For each function, the \f2excepts\f1 argument specifies one or more exceptions indicated by a bitwise "or" of any of the following values (defined in \f3\f1): .LP .RS .PD 0 .TP 20 \s-1FE_INEXACT\s0 .TP \s-1FE_UNDERFLOW\s0 .TP \s-1FE_OVERFLOW\s0 .TP \s-1FE_DIVBYZERO\s0 .TP \s-1FE_INVALID\s0 .PD .RE .LP For convenience, the macro \s-1FE_ALL_EXCEPT\s0 is defined to be the bitwise "or" of all of the above values. .LP \f3feclearexcept(\f2excepts\f3)\f1 clears the flags for the specified exceptions. .LP \f3feraiseexcept(\f2excepts\f3)\f1 raises the specified exceptions: for each exception indicated, if \s-1FEX_NONSTOP\s0 handling mode is in effect, the exception's flag is set, and otherwise the appropriate action is taken as described in \f3fex_set_handling\f1(3M). .LP \f3fetestexcept(\f2excepts\f3)\f1 returns a bitwise "or" of the values listed above corresponding to the subset of the specified exceptions whose flags are set. .LP \f3fegetexceptflag(\f2flagp\f3, \f2excepts\f3)\f1 saves the current values of the flags for the exceptions indicated by \f2excepts\f1 in the object pointed to by \f2flagp\f1. The type \f3fexcept_t\f1 is defined in \f3\f1. .LP \f3fesetexceptflag(\f2flagp\f3, \f2excepts\f3)\f1 restores the values of the flags for the exceptions indicated by \f2excepts\f1 from the object pointed to by \f2flagp\f1. This object must have been set by a previous call to \f3fegetexceptflag(\|)\f1; otherwise the effect on the indicated flags is undefined. (The \f3fesetexceptflag\f1 function does not raise exceptions, but only sets the state of the flags.) .SH EXAMPLE The following code fragment calls the function \f3f(\|)\f1 if the invalid operation flag is set and \f3g(\|)\f1 if the overflow flag is set: .LP .RS .nf .vs 11p .ft B .ne 12 #include /*...*/ { int set_excepts; feclearexcept(FE_INVALID | FE_OVERFLOW); /* computation that may raise exceptions */ set_excepts = fetestexcept(FE_INVALID | FE_OVERFLOW); if (set_excepts & FE_INVALID) f(); if (set_excepts & FE_OVERFLOW) g(); /*...*/ } .vs .fi .RE .LP .SH ATTRIBUTES See .BR attributes (5) for descriptions of the following attributes: .sp .ne 10 .TS box; cbp-1 | cbp-1 l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE = Availability SPROm9xs Interface Stability Stable (see below) MT-Level MT-Safe .TE .LP The \f3feclearexcept\f1, \f3feraiseexcept\f1, \f3fetestexcept\f1, \f3fegetexceptflag\f1, and \f3fesetexceptflag\f1 functions are defined by the C9X draft standard. Should the final standard change the definitions of these functions, new conforming implementations will be provided in a subsequent major release. Therefore, these functions should currently be considered Evolving. .LP To maintain compatibility with the present C9X definitions, programs may instead use the \f3feclearexcept96\f1, \f3feraiseexcept96\f1, \f3fetestexcept96\f1, \f3fegetexceptflag96\f1, and \f3fesetexceptflag96\f1 functions. Each of these functions currently performs the same operation as its counterpart without the \f396\f1 suffix. The suffixed functions, however, will retain their present definitions regardless of changes to the C9X draft. These functions are Stable. .LP Note that \f3\f1 currently redefines the names of the standard functions to their suffixed counterparts so that compiled programs will invoke the suffixed functions. Once the C9X draft is adopted as a standard, those redefinitions will be removed from \f3\f1. Any program recompiled thereafter that uses the standard, unsuffixed names will then invoke the standard functions (with their final definitions), but previously compiled programs will be unaffected. .SH "SEE ALSO" .BR fegetenv (3M), .BR fex_set_handling (3M), .BR fex_set_log (3M), .BR attributes (5) .LP .I Numerical Computation Guide .SH NOTES When the \s-1FEX_CUSTOM\s0 handling mode is in effect for an exception, raising that exception via \f3feraiseexcept\f1 will cause the handling function to be invoked. The handling function may then modify the exception flags to be set as described in \f3fex_set_handling\f1(3M). Any result value the handler supplies will be ignored. .LP As shown in the synopsis, the recommended way to link with libm9x using \f3cc\f1 is to specify .LP .RS .BI -R install-path "/lib -L" install-path "/lib -lm9x" .RE .LP on the command line, where \f2install-path\f1 refers to the location in which the compilers are installed (/opt/SUNWspro by default). See the \f3Numerical Computation Guide\f1 or the READMEs/math_libraries file in the compiler installation area for additional information about linking with libm9x.