| |
| .. module:: fpectl |
| :platform: Unix |
| :synopsis: Provide control for floating point exception handling. |
| .. moduleauthor:: Lee Busby <busby1@llnl.gov> |
| .. sectionauthor:: Lee Busby <busby1@llnl.gov> |
| |
| |
n | .. note:: |
| |
| The :mod:`fpectl` module is not built by default, and its usage is discouraged |
| and may be dangerous except in the hands of experts. See also the section |
| :ref:`fpectl-limitations` on limitations for more details. |
| |
| .. index:: single: IEEE-754 |
| |
n | Most computers carry out floating point operations in conformance with the so- |
n | Most computers carry out floating point operations in conformance with the |
| called IEEE-754 standard. On any real computer, some floating point operations |
| so-called IEEE-754 standard. On any real computer, some floating point |
| produce results that cannot be expressed as a normal floating point value. For |
| operations produce results that cannot be expressed as a normal floating point |
| example, try :: |
| value. For example, try :: |
| |
| >>> import math |
| >>> math.exp(1000) |
| inf |
| >>> math.exp(1000) / math.exp(1000) |
| nan |
| |
| (The example above will work on many platforms. DEC Alpha may be one exception.) |
| [ more output from test elided ] |
| >>> import math |
| >>> math.exp(1000) |
| Traceback (most recent call last): |
| File "<stdin>", line 1, in ? |
| FloatingPointError: in math_1 |
| |
| |
t | .. _fpectl-limitations: |
| |
| Limitations and other considerations |
| ------------------------------------ |
| |
| Setting up a given processor to trap IEEE-754 floating point errors currently |
| requires custom code on a per-architecture basis. You may have to modify |
| :mod:`fpectl` to control your particular hardware. |
| |
| Conversion of an IEEE-754 exception to a Python exception requires that the |