Specifies floating-point exception handling for the main program at run-time.
Windows: Floating-Point > Floating-Point
Exception Handling
Linux: None
IA-32, IntelŪ EM64T, IntelŪ ItaniumŪ architecture
Linux: | -fpen |
Windows: | /fpe:n |
n | Is the floating-point exception level. Possible values are 0, 1, or 3. |
3 | The floating-point invalid, divide-by-zero, and overflow exceptions produce exceptional values and execution continues. Floating-point underflow is gradual. This setting provides full IEEE support. |
This option specifies floating-point exception handling for the main program at run-time. This includes whether exceptional floating-point values are allowed and how precisely run-time exceptions are reported.
The following are the kinds of floating-point exceptions affected by this option:
Floating-point overflow
Overflow occurs whenever the destination format's largest finite number
is exceeded in magnitude by what would have been the rounded floating-point
result. The result computed is rounding-mode specific:
Round-to-nearest mode (the default) produces a result of +/- Infinity in the specified precision.
Round-to-zero mode produces a result of +/-Maximum Number in the specified precision.
Round-to-+Infinity mode produces a result of +Infinity or -(Maximum Positive Number) in the specified precision.
Round-to--Infinity mode produces a result of (Maximum Positive Number) or -Infinity in the specified precision.
For example, in round-to-nearest mode, 1E30 * 1E30 overflows the single-precision floating-point range and results in a +Infinity; -1E30 * 1E30 results in a -Infinity.
Floating-point divide-by-zero
Divide-by-zero occurs when the divisor is zero and the dividend is a finite nonzero number. The computed result is a correctly signed Infinity.
For example, 2.0E0/+0.0 produces a divide-by-zero exception and results in a +Infinity; -2.0E0/+0.0 produces a divide-by-zero exception and results in a -Infinity.
Floating-point underflow
Underflow occurs when a computed result falls beyond the minimum range in magnitude of normalized numbers of the floating-point data type. Each floating-point type (32-, 64-, and 128-bit) has a denormalized range where very small numbers can be represented with some loss of precision. This is called gradual underflow.
For example, the lower bound for normalized single-precision float-point is approximately 1E-38, while the lower bound for denormalized single-precision float-point is approximately 1E-45. Results falling below the lower bound of the denormalized range simply become zero. 1E-30 / 1E10 underflows the normalized range but not the denormalized range so the result is the denormal value 1E-40. 1E-30 / 1E30 underflows the range and the result is zero.
Floating-point invalid
Invalid occurs when operands to the basic floating-point operations or math function produce an undefined or "Quiet Nan" (QNaN) result.
Some examples include:
0.0/0.0
A "Signaling Nan" (SNaN) operand in any floating-point operation or math function call
A sum of Infinities with different signs: (+/Infinity) + (-/+Infinity)
The difference of Infinities with the same sign: (+/-Infinity) - (+/-Infinity)
A product of signed Infinities with zero: (+/-Inf) * 0
Math Function Domain Errors: log(negative), sqrt(negative), asin(|x}>1), etc.
The fpe option controls how the following conditions are handled:
When floating-point calculations result in a divide by zero, overflow, or invalid operation.
When floating-point calculations result in an underflow.
When a denormalized number or other exceptional number (positive infinity, negative infinity, or a NaN) is present in an arithmetic expression.
None
ftz, Qftz compiler options
Building Applications: Using the Floating Point Exception Handling (-fpe) Option