'\" t .\" @(#)feclearexcept.3m 1.5 00/01/01 SMI .TH feclearexcept 3M "01/01/00" .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 .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" .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 Standard MT-Level MT-Safe .TE .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 \f2Numerical Computation Guide\f1 for additional information about linking with libm9x.