Floating Point Exceptions and Interrupts

Floating point exceptions

Roughly, the word "exception" is used to describe a condition which is expected to occur infrequently and might require an exceptional response. Often, but not always, an exception is also an error condition.

Examples of floating point exceptions are:

When a floating point exception condition is detected by an Intel 80x86 FPU performing a floating point operation, a flag in the FPU status register is set. Other action depends upon the state of the corresponding bit in the FPU control register. If the bit is zero, then the exception is refered to as unmasked and in addition to other effects which may occur, an interrupt will occur when the next FPU instruction is encountered. If the exception is masked, the action depends upon the particular FPU operation, but no interrupt will be generated.


Floating point overflow occurs when the result of a floating point operation cannot be represented in the specified format.


Floating point interrupts

On the Intel 80x86 FPU architecture, a floating point interrupt is a hardware interrupt which will occur when the following simultaneously occur:

Operating systems such as Linux will respond to the floating point interrupt by passing a SIGFPE signal to the user process as required.

A user process which receives a SIGFPE signal can determine which instruction caused the interrupt by doing the following:

For an example of how to handle a SIGFPE signal, see the wmexcp package.