包含在尋找其他文件熱門支援資源 | 以 PDF 格式下載這本書 (2106 KB)
2.4 Floating Point, Nonstandard ModeIEEE 754 floating-point default arithmetic is “nonstop.” Underflows are “gradual.” The following is a summary, see the Numerical Computation Guide for details. 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. Here is how gradual underflow works. Suppose you have the following code:
The first time through the loop, x is set to 1; the second time through, to 0.1; the third time through, 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? Let’s say 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 is known as “gradual underflow,” which is the default behavior. In nonstandard mode, none of this “stealing” takes place; typically, x is simply set to zero. |
|