This section provides a summary of IEEE 754 floating-point default arithmetic, which is “ nonstop.” Underflows are “ gradual.” For more detailed information, see the Oracle Developer Studio 12.6: Numerical Computation Guide.
Nonstop means that execution does not halt on occurrences like division by zero, floating-point overflow, or invalid operation exceptions. For example, consider the following, where x is zero and y is positive:
z = y / x;
By default, z is set to the value +Inf, and execution continues. With the –fnonstd option, however, this code causes an exit, such as a core dump.
The following example shows how gradual underflow works. Suppose you have the following code:
x = 10; for (i = 0; i < LARGE_NUMBER; i++) x = x / 10;
The first time through the loop, x is set to 1; the second time to 0.1; the third time to 0.01; and so on. Eventually, x reaches the lower limit of the machine’s capacity to represent its value. What happens the next time the loop runs?
Assume that the smallest number characterizable is 1.234567e-38.
The next time the loop runs, the number is modified by “stealing” from the mantissa and “giving” to the exponent so the new value is 1.23456e-39 and, subsequently, 1.2345e-40 and so on. This behavior is known as “gradual underflow,” and is the default. In nonstandard mode, none of this “stealing” takes place, and x is simply set to zero.