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
@@ -1096,40 +1096,52 @@ In addition to the three supplied contexts, new contexts can be created with the
1096
1096
default values are copied from the :const: `DefaultContext `. If the *flags *
1097
1097
field is not specified or is :const: `None `, all flags are cleared.
1098
1098
1099
- *prec * is an integer in the range [``1 ``, :const: `MAX_PREC `] that sets
1100
- the precision for arithmetic operations in the context.
1099
+ .. attribute :: prec
1101
1100
1102
- The * rounding * option is one of the constants listed in the section
1103
- ` Rounding Modes `_ .
1101
+ An integer in the range [`` 1 ``, :const: ` MAX_PREC `] that sets
1102
+ the precision for arithmetic operations in the context .
1104
1103
1105
- The *traps * and *flags * fields list any signals to be set. Generally, new
1106
- contexts should only set traps and leave the flags clear.
1104
+ .. attribute :: rounding
1107
1105
1108
- The *Emin * and *Emax * fields are integers specifying the outer limits allowable
1109
- for exponents. *Emin * must be in the range [:const: `MIN_EMIN `, ``0 ``],
1110
- *Emax * in the range [``0 ``, :const: `MAX_EMAX `].
1106
+ One of the constants listed in the section `Rounding Modes `_.
1111
1107
1112
- The *capitals * field is either ``0 `` or ``1 `` (the default). If set to
1113
- ``1 ``, exponents are printed with a capital ``E ``; otherwise, a
1114
- lowercase ``e `` is used: ``Decimal('6.02e+23') ``.
1108
+ .. attribute :: traps
1109
+ flags
1115
1110
1116
- The *clamp * field is either ``0 `` (the default) or ``1 ``.
1117
- If set to ``1 ``, the exponent ``e `` of a :class: `Decimal `
1118
- instance representable in this context is strictly limited to the
1119
- range ``Emin - prec + 1 <= e <= Emax - prec + 1 ``. If *clamp * is
1120
- ``0 `` then a weaker condition holds: the adjusted exponent of
1121
- the :class: `Decimal ` instance is at most :attr: `~Context.Emax `. When *clamp * is
1122
- ``1 ``, a large normal number will, where possible, have its
1123
- exponent reduced and a corresponding number of zeros added to its
1124
- coefficient, in order to fit the exponent constraints; this
1125
- preserves the value of the number but loses information about
1126
- significant trailing zeros. For example::
1111
+ Lists of any signals to be set. Generally, new contexts should only set
1112
+ traps and leave the flags clear.
1127
1113
1128
- >>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
1129
- Decimal('1.23000E+999')
1114
+ .. attribute :: Emin
1115
+ Emax
1130
1116
1131
- A *clamp * value of ``1 `` allows compatibility with the
1132
- fixed-width decimal interchange formats specified in IEEE 754.
1117
+ Integers specifying the outer limits allowable for exponents. *Emin * must
1118
+ be in the range [:const: `MIN_EMIN `, ``0 ``], *Emax * in the range
1119
+ [``0 ``, :const: `MAX_EMAX `].
1120
+
1121
+ .. attribute :: capitals
1122
+
1123
+ Either ``0 `` or ``1 `` (the default). If set to
1124
+ ``1 ``, exponents are printed with a capital ``E ``; otherwise, a
1125
+ lowercase ``e `` is used: ``Decimal('6.02e+23') ``.
1126
+
1127
+ .. attribute :: clamp
1128
+
1129
+ Either ``0 `` (the default) or ``1 ``. If set to ``1 ``, the exponent ``e ``
1130
+ of a :class: `Decimal ` instance representable in this context is strictly
1131
+ limited to the range ``Emin - prec + 1 <= e <= Emax - prec + 1 ``.
1132
+ If *clamp * is ``0 `` then a weaker condition holds: the adjusted exponent of
1133
+ the :class: `Decimal ` instance is at most :attr: `~Context.Emax `. When *clamp * is
1134
+ ``1 ``, a large normal number will, where possible, have its
1135
+ exponent reduced and a corresponding number of zeros added to its
1136
+ coefficient, in order to fit the exponent constraints; this
1137
+ preserves the value of the number but loses information about
1138
+ significant trailing zeros. For example::
1139
+
1140
+ >>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
1141
+ Decimal('1.23000E+999')
1142
+
1143
+ A *clamp * value of ``1 `` allows compatibility with the
1144
+ fixed-width decimal interchange formats specified in IEEE 754.
1133
1145
1134
1146
The :class: `Context ` class defines several general purpose methods as well as
1135
1147
a large number of methods for doing arithmetic directly in a given context.
@@ -1769,7 +1781,7 @@ The following table summarizes the hierarchy of signals::
1769
1781
1770
1782
.. _decimal-notes :
1771
1783
1772
- Floating-Point Notes
1784
+ Floating-point notes
1773
1785
--------------------
1774
1786
1775
1787
0 commit comments