Oracle® Solaris Studio 12.4: Numerical Computation Guide

Exit Print View

Updated: January 2015
 
 

4.3 Detecting Exceptions

As required by the IEEE standard, the floating-point environments on SPARC-based systems and x86-based systems provide status flags that record the occurrence of floating-point exceptions. A program can test these flags to determine which exceptions have occurred. The flags can also be explicitly set and cleared. The ieee_flags function provides one way to access these flags. In programs written in C or C++, the C99 floating-point environment functions provide another.

On SPARC-based systems, each exception has two flags associated with it, current and accrued. The current exception flags always indicate the exceptions raised by the last floating-point instruction to complete execution. These flags are also accumulated (i.e., “or”‐ed) into the accrued exception flags thereby providing a record of all untrapped exceptions that have occurred since the program began execution or since the accrued flags were last cleared by the program. When a floating-point instruction incurs a trapped exception, the current exception flag corresponding to the exception that caused the trap is set, but the accrued flags are unchanged. Both the current and accrued exception flags are contained in the floating-point status register, %fsr.

On x86-based systems, the floating-point status word (SW) provides flags for accrued exceptions as well as flags for the status of the floating-point stack. On x86-based systems that support SSE2 instructions, the MXCSR register contains flags that record accrued exceptions raised by those instructions.