|
2 | 2 | =====================================================================
|
3 | 3 |
|
4 | 4 | .. module:: decimal
|
5 |
| - :synopsis: Implementation of the General Decimal Arithmetic Specification. |
| 5 | + :synopsis: Implementation of the General Decimal Arithmetic Specification. |
6 | 6 |
|
7 | 7 | .. moduleauthor:: Eric Price <eprice at tjhsst.edu>
|
8 | 8 | .. moduleauthor:: Facundo Batista <facundo at taniquetil.com.ar>
|
@@ -121,7 +121,7 @@ reset them before monitoring a calculation.
|
121 | 121 |
|
122 | 122 | .. _decimal-tutorial:
|
123 | 123 |
|
124 |
| -Quick-start Tutorial |
| 124 | +Quick-start tutorial |
125 | 125 | --------------------
|
126 | 126 |
|
127 | 127 | The usual start to using decimals is importing the module, viewing the current
|
@@ -1071,40 +1071,52 @@ In addition to the three supplied contexts, new contexts can be created with the
|
1071 | 1071 | default values are copied from the :const:`DefaultContext`. If the *flags*
|
1072 | 1072 | field is not specified or is :const:`None`, all flags are cleared.
|
1073 | 1073 |
|
1074 |
| - *prec* is an integer in the range [``1``, :const:`MAX_PREC`] that sets |
1075 |
| - the precision for arithmetic operations in the context. |
| 1074 | + .. attribute:: prec |
1076 | 1075 |
|
1077 |
| - The *rounding* option is one of the constants listed in the section |
1078 |
| - `Rounding Modes`_. |
| 1076 | + An integer in the range [``1``, :const:`MAX_PREC`] that sets |
| 1077 | + the precision for arithmetic operations in the context. |
1079 | 1078 |
|
1080 |
| - The *traps* and *flags* fields list any signals to be set. Generally, new |
1081 |
| - contexts should only set traps and leave the flags clear. |
| 1079 | + .. attribute:: rounding |
1082 | 1080 |
|
1083 |
| - The *Emin* and *Emax* fields are integers specifying the outer limits allowable |
1084 |
| - for exponents. *Emin* must be in the range [:const:`MIN_EMIN`, ``0``], |
1085 |
| - *Emax* in the range [``0``, :const:`MAX_EMAX`]. |
| 1081 | + One of the constants listed in the section `Rounding Modes`_. |
1086 | 1082 |
|
1087 |
| - The *capitals* field is either ``0`` or ``1`` (the default). If set to |
1088 |
| - ``1``, exponents are printed with a capital ``E``; otherwise, a |
1089 |
| - lowercase ``e`` is used: ``Decimal('6.02e+23')``. |
| 1083 | + .. attribute:: traps |
| 1084 | + flags |
1090 | 1085 |
|
1091 |
| - The *clamp* field is either ``0`` (the default) or ``1``. |
1092 |
| - If set to ``1``, the exponent ``e`` of a :class:`Decimal` |
1093 |
| - instance representable in this context is strictly limited to the |
1094 |
| - range ``Emin - prec + 1 <= e <= Emax - prec + 1``. If *clamp* is |
1095 |
| - ``0`` then a weaker condition holds: the adjusted exponent of |
1096 |
| - the :class:`Decimal` instance is at most :attr:`~Context.Emax`. When *clamp* is |
1097 |
| - ``1``, a large normal number will, where possible, have its |
1098 |
| - exponent reduced and a corresponding number of zeros added to its |
1099 |
| - coefficient, in order to fit the exponent constraints; this |
1100 |
| - preserves the value of the number but loses information about |
1101 |
| - significant trailing zeros. For example:: |
| 1086 | + Lists of any signals to be set. Generally, new contexts should only set |
| 1087 | + traps and leave the flags clear. |
1102 | 1088 |
|
1103 |
| - >>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999') |
1104 |
| - Decimal('1.23000E+999') |
| 1089 | + .. attribute:: Emin |
| 1090 | + Emax |
1105 | 1091 |
|
1106 |
| - A *clamp* value of ``1`` allows compatibility with the |
1107 |
| - fixed-width decimal interchange formats specified in IEEE 754. |
| 1092 | + Integers specifying the outer limits allowable for exponents. *Emin* must |
| 1093 | + be in the range [:const:`MIN_EMIN`, ``0``], *Emax* in the range |
| 1094 | + [``0``, :const:`MAX_EMAX`]. |
| 1095 | + |
| 1096 | + .. attribute:: capitals |
| 1097 | + |
| 1098 | + Either ``0`` or ``1`` (the default). If set to |
| 1099 | + ``1``, exponents are printed with a capital ``E``; otherwise, a |
| 1100 | + lowercase ``e`` is used: ``Decimal('6.02e+23')``. |
| 1101 | + |
| 1102 | + .. attribute:: clamp |
| 1103 | + |
| 1104 | + Either ``0`` (the default) or ``1``. If set to ``1``, the exponent ``e`` |
| 1105 | + of a :class:`Decimal` instance representable in this context is strictly |
| 1106 | + limited to the range ``Emin - prec + 1 <= e <= Emax - prec + 1``. |
| 1107 | + If *clamp* is ``0`` then a weaker condition holds: the adjusted exponent of |
| 1108 | + the :class:`Decimal` instance is at most :attr:`~Context.Emax`. When *clamp* is |
| 1109 | + ``1``, a large normal number will, where possible, have its |
| 1110 | + exponent reduced and a corresponding number of zeros added to its |
| 1111 | + coefficient, in order to fit the exponent constraints; this |
| 1112 | + preserves the value of the number but loses information about |
| 1113 | + significant trailing zeros. For example:: |
| 1114 | + |
| 1115 | + >>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999') |
| 1116 | + Decimal('1.23000E+999') |
| 1117 | + |
| 1118 | + A *clamp* value of ``1`` allows compatibility with the |
| 1119 | + fixed-width decimal interchange formats specified in IEEE 754. |
1108 | 1120 |
|
1109 | 1121 | The :class:`Context` class defines several general purpose methods as well as
|
1110 | 1122 | a large number of methods for doing arithmetic directly in a given context.
|
@@ -1743,7 +1755,7 @@ The following table summarizes the hierarchy of signals::
|
1743 | 1755 |
|
1744 | 1756 | .. _decimal-notes:
|
1745 | 1757 |
|
1746 |
| -Floating-Point Notes |
| 1758 | +Floating-point notes |
1747 | 1759 | --------------------
|
1748 | 1760 |
|
1749 | 1761 |
|
|
0 commit comments