@@ -94,7 +94,7 @@ differentiates :const:`!-0` from :const:`!+0`.
94
94
The context for arithmetic is an environment specifying precision, rounding
95
95
rules, limits on exponents, flags indicating the results of operations, and trap
96
96
enablers which determine whether signals are treated as exceptions. Rounding
97
- options include :const: `~decimal. ROUND_CEILING `, :const: `ROUND_DOWN `,
97
+ options include :const: `ROUND_CEILING `, :const: `ROUND_DOWN `,
98
98
:const: `ROUND_FLOOR `, :const: `ROUND_HALF_DOWN `, :const: `ROUND_HALF_EVEN `,
99
99
:const: `ROUND_HALF_UP `, :const: `ROUND_UP `, and :const: `ROUND_05UP `.
100
100
@@ -250,7 +250,7 @@ And some mathematical functions are also available to Decimal:
250
250
>>> Decimal(' 10' ).log10()
251
251
Decimal('1')
252
252
253
- The :meth: `~decimal. Decimal.quantize ` method rounds a number to a fixed exponent. This method is
253
+ The :meth: `~Decimal.quantize ` method rounds a number to a fixed exponent. This method is
254
254
useful for monetary applications that often round results to a fixed number of
255
255
places:
256
256
@@ -299,7 +299,7 @@ enabled:
299
299
Contexts also have signal flags for monitoring exceptional conditions
300
300
encountered during computations. The flags remain set until explicitly cleared,
301
301
so it is best to clear the flags before each set of monitored computations by
302
- using the :meth: `~decimal. Context.clear_flags ` method. ::
302
+ using the :meth: `~Context.clear_flags ` method. ::
303
303
304
304
>>> setcontext(ExtendedContext)
305
305
>>> getcontext().clear_flags()
@@ -313,8 +313,8 @@ The *flags* entry shows that the rational approximation to :const:`!Pi` was
313
313
rounded (digits beyond the context precision were thrown away) and that the
314
314
result is inexact (some of the discarded digits were non-zero).
315
315
316
- Individual traps are set using the dictionary in the :attr: `! traps ` field of a
317
- context:
316
+ Individual traps are set using the dictionary in the :attr: `~Context. traps `
317
+ attribute of a context:
318
318
319
319
.. doctest :: newcontext
320
320
@@ -790,7 +790,7 @@ Decimal objects
790
790
the current thread's context is used.
791
791
792
792
An error is returned whenever the resulting exponent is greater than
793
- :attr: `! Emax ` or less than :attr: ` ! Etiny `.
793
+ :attr: `Emax ` or less than :meth: ` Etiny `.
794
794
795
795
.. method :: radix()
796
796
@@ -892,8 +892,8 @@ Decimal objects
892
892
Logical operands
893
893
^^^^^^^^^^^^^^^^
894
894
895
- The :meth: `~decimal. Decimal.logical_and `, :meth: `~decimal. Decimal.logical_invert `, :meth: `~decimal. Decimal.logical_or `,
896
- and :meth: `~decimal. Decimal.logical_xor ` methods expect their arguments to be *logical
895
+ The :meth: `~Decimal.logical_and `, :meth: `~Decimal.logical_invert `, :meth: `~Decimal.logical_or `,
896
+ and :meth: `~Decimal.logical_xor ` methods expect their arguments to be *logical
897
897
operands *. A *logical operand * is a :class: `Decimal ` instance whose
898
898
exponent and sign are both zero, and whose digits are all either
899
899
:const: `!0 ` or :const: `!1 `.
@@ -1001,8 +1001,8 @@ described below. In addition, the module provides three pre-made contexts:
1001
1001
In single threaded environments, it is preferable to not use this context at
1002
1002
all. Instead, simply create contexts explicitly as described below.
1003
1003
1004
- The default values are :attr: `! prec `\ =\ :const: ` !28 `,
1005
- :attr: `! rounding `\ =\ :const: `ROUND_HALF_EVEN `,
1004
+ The default values are :attr: `Context. prec `\ =\ `` 28 ` `,
1005
+ :attr: `Context. rounding `\ =\ :const: `ROUND_HALF_EVEN `,
1006
1006
and enabled traps for :class: `Overflow `, :class: `InvalidOperation `, and
1007
1007
:class: `DivisionByZero `.
1008
1008
@@ -1054,7 +1054,7 @@ In addition to the three supplied contexts, new contexts can be created with the
1054
1054
The :class: `Context ` class defines several general purpose methods as well as
1055
1055
a large number of methods for doing arithmetic directly in a given context.
1056
1056
In addition, for each of the :class: `Decimal ` methods described above (with
1057
- the exception of the :meth: `~decimal. Decimal.adjusted ` and :meth: `~decimal. Decimal.as_tuple ` methods) there is
1057
+ the exception of the :meth: `~Decimal.adjusted ` and :meth: `~Decimal.as_tuple ` methods) there is
1058
1058
a corresponding :class: `Context ` method. For example, for a :class: `Context `
1059
1059
instance ``C `` and :class: `Decimal ` instance ``x ``, ``C.exp(x) `` is
1060
1060
equivalent to ``x.exp(context=C) ``. Each :class: `Context ` method accepts a
@@ -1570,7 +1570,7 @@ condition.
1570
1570
Altered an exponent to fit representation constraints.
1571
1571
1572
1572
Typically, clamping occurs when an exponent falls outside the context's
1573
- :attr: `! Emin ` and :attr: `! Emax ` limits. If possible, the exponent is reduced to
1573
+ :attr: `~Context. Emin ` and :attr: `~Context. Emax ` limits. If possible, the exponent is reduced to
1574
1574
fit by adding zeros to the coefficient.
1575
1575
1576
1576
@@ -1638,7 +1638,7 @@ condition.
1638
1638
1639
1639
.. class :: Subnormal
1640
1640
1641
- Exponent was lower than :attr: `! Emin ` prior to rounding.
1641
+ Exponent was lower than :attr: `~Context. Emin ` prior to rounding.
1642
1642
1643
1643
Occurs when an operation result is subnormal (the exponent is too small). If
1644
1644
not trapped, returns the result unchanged.
@@ -1780,8 +1780,8 @@ if either operand is a :const:`!NaN`, and return :const:`False` if this signal i
1780
1780
not trapped. Note that the General Decimal Arithmetic specification does not
1781
1781
specify the behavior of direct comparisons; these rules for comparisons
1782
1782
involving a :const: `!NaN ` were taken from the IEEE 854 standard (see Table 3 in
1783
- section 5.7). To ensure strict standards-compliance, use the :meth: `~decimal. Decimal.compare `
1784
- and :meth: `~decimal. Decimal.compare_signal ` methods instead.
1783
+ section 5.7). To ensure strict standards-compliance, use the :meth: `~Decimal.compare `
1784
+ and :meth: `~Decimal.compare_signal ` methods instead.
1785
1785
1786
1786
The signed zeros can result from calculations that underflow. They keep the sign
1787
1787
that would have resulted if the calculation had been carried out to greater
@@ -2013,7 +2013,7 @@ Q. In a fixed-point application with two decimal places, some inputs have many
2013
2013
places and need to be rounded. Others are not supposed to have excess digits
2014
2014
and need to be validated. What methods should be used?
2015
2015
2016
- A. The :meth: `~decimal. Decimal.quantize ` method rounds to a fixed number of decimal places. If
2016
+ A. The :meth: `~Decimal.quantize ` method rounds to a fixed number of decimal places. If
2017
2017
the :const: `Inexact ` trap is set, it is also useful for validation:
2018
2018
2019
2019
>>> TWOPLACES = Decimal(10 ) ** - 2 # same as Decimal('0.01')
@@ -2037,7 +2037,7 @@ throughout an application?
2037
2037
A. Some operations like addition, subtraction, and multiplication by an integer
2038
2038
will automatically preserve fixed point. Others operations, like division and
2039
2039
non-integer multiplication, will change the number of decimal places and need to
2040
- be followed-up with a :meth: `~decimal. Decimal.quantize ` step:
2040
+ be followed-up with a :meth: `~Decimal.quantize ` step:
2041
2041
2042
2042
>>> a = Decimal(' 102.72' ) # Initial fixed-point values
2043
2043
>>> b = Decimal(' 3.17' )
@@ -2053,7 +2053,7 @@ be followed-up with a :meth:`~decimal.Decimal.quantize` step:
2053
2053
Decimal('0.03')
2054
2054
2055
2055
In developing fixed-point applications, it is convenient to define functions
2056
- to handle the :meth: `~decimal. Decimal.quantize ` step:
2056
+ to handle the :meth: `~Decimal.quantize ` step:
2057
2057
2058
2058
>>> def mul (x , y , fp = TWOPLACES ):
2059
2059
... return (x * y).quantize(fp)
@@ -2071,7 +2071,7 @@ Q. There are many ways to express the same value. The numbers :const:`!200`,
2071
2071
various precisions. Is there a way to transform them to a single recognizable
2072
2072
canonical value?
2073
2073
2074
- A. The :meth: `~decimal. Decimal.normalize ` method maps all equivalent values to a single
2074
+ A. The :meth: `~Decimal.normalize ` method maps all equivalent values to a single
2075
2075
representative:
2076
2076
2077
2077
>>> values = map (Decimal, ' 200 200.000 2E2 .02E+4' .split())
@@ -2159,12 +2159,12 @@ for medium-sized numbers and the `Number Theoretic Transform
2159
2159
<https://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general)#Number-theoretic_transform> `_
2160
2160
for very large numbers.
2161
2161
2162
- The context must be adapted for exact arbitrary precision arithmetic. :attr: `! Emin `
2163
- and :attr: `! Emax ` should always be set to the maximum values, :attr: `! clamp `
2164
- should always be 0 (the default). Setting :attr: `! prec ` requires some care.
2162
+ The context must be adapted for exact arbitrary precision arithmetic. :attr: `~Context. Emin `
2163
+ and :attr: `~Context. Emax ` should always be set to the maximum values, :attr: `~Context. clamp `
2164
+ should always be 0 (the default). Setting :attr: `~Context. prec ` requires some care.
2165
2165
2166
2166
The easiest approach for trying out bignum arithmetic is to use the maximum
2167
- value for :attr: `! prec ` as well [# ]_::
2167
+ value for :attr: `~Context. prec ` as well [# ]_::
2168
2168
2169
2169
>>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))
2170
2170
>>> x = Decimal(2) ** 256
@@ -2181,7 +2181,7 @@ the available memory will be insufficient::
2181
2181
MemoryError
2182
2182
2183
2183
On systems with overallocation (e.g. Linux), a more sophisticated approach is to
2184
- adjust :attr: `! prec ` to the amount of available RAM. Suppose that you have 8GB of
2184
+ adjust :attr: `~Context. prec ` to the amount of available RAM. Suppose that you have 8GB of
2185
2185
RAM and expect 10 simultaneous operands using a maximum of 500MB each::
2186
2186
2187
2187
>>> import sys
0 commit comments