Skip to content

Commit 498e6f8

Browse files
committed
Replace :const: roles with literals
1 parent d941dea commit 498e6f8

File tree

1 file changed

+64
-64
lines changed

1 file changed

+64
-64
lines changed

Doc/library/decimal.rst

+64-64
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ decimal floating point arithmetic. It offers several advantages over the
4040
people learn at school." -- excerpt from the decimal arithmetic specification.
4141

4242
* Decimal numbers can be represented exactly. In contrast, numbers like
43-
:const:`!1.1` and :const:`!2.2` do not have exact representations in binary
43+
``1.1`` and ``2.2`` do not have exact representations in binary
4444
floating point. End users typically would not expect ``1.1 + 2.2`` to display
45-
as :const:`!3.3000000000000003` as it does with binary floating point.
45+
as ``3.3000000000000003`` as it does with binary floating point.
4646

4747
* The exactness carries over into arithmetic. In decimal floating point, ``0.1
4848
+ 0.1 + 0.1 - 0.3`` is exactly equal to zero. In binary floating point, the result
49-
is :const:`!5.5511151231257827e-017`. While near to zero, the differences
49+
is ``5.5511151231257827e-017``. While near to zero, the differences
5050
prevent reliable equality testing and differences can accumulate. For this
5151
reason, decimal is preferred in accounting applications which have strict
5252
equality invariants.
5353

5454
* The decimal module incorporates a notion of significant places so that ``1.30
55-
+ 1.20`` is :const:`!2.50`. The trailing zero is kept to indicate significance.
55+
+ 1.20`` is ``2.50``. The trailing zero is kept to indicate significance.
5656
This is the customary presentation for monetary applications. For
5757
multiplication, the "schoolbook" approach uses all the figures in the
58-
multiplicands. For instance, ``1.3 * 1.2`` gives :const:`!1.56` while ``1.30 *
59-
1.20`` gives :const:`!1.5600`.
58+
multiplicands. For instance, ``1.3 * 1.2`` gives ``1.56`` while ``1.30 *
59+
1.20`` gives ``1.5600``.
6060

6161
* Unlike hardware based binary floating point, the decimal module has a user
6262
alterable precision (defaulting to 28 places) which can be as large as needed for
@@ -88,8 +88,8 @@ context for arithmetic, and signals.
8888
A decimal number is immutable. It has a sign, coefficient digits, and an
8989
exponent. To preserve significance, the coefficient digits do not truncate
9090
trailing zeros. Decimals also include special values such as
91-
:const:`!Infinity`, :const:`!-Infinity`, and :const:`!NaN`. The standard also
92-
differentiates :const:`!-0` from :const:`!+0`.
91+
``Infinity``, ``-Infinity``, and ``NaN``. The standard also
92+
differentiates ``-0`` from ``+0``.
9393

9494
The context for arithmetic is an environment specifying precision, rounding
9595
rules, limits on exponents, flags indicating the results of operations, and trap
@@ -139,8 +139,8 @@ precision, rounding, or enabled traps::
139139
Decimal instances can be constructed from integers, strings, floats, or tuples.
140140
Construction from an integer or a float performs an exact conversion of the
141141
value of that integer or float. Decimal numbers include special values such as
142-
:const:`!NaN` which stands for "Not a number", positive and negative
143-
:const:`!Infinity`, and :const:`!-0`::
142+
``NaN`` which stands for "Not a number", positive and negative
143+
``Infinity``, and ``-0``::
144144

145145
>>> getcontext().prec = 28
146146
>>> Decimal(10)
@@ -309,7 +309,7 @@ using the :meth:`~Context.clear_flags` method. ::
309309
Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
310310
capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[])
311311

312-
The *flags* entry shows that the rational approximation to :const:`!Pi` was
312+
The *flags* entry shows that the rational approximation to ``Pi`` was
313313
rounded (digits beyond the context precision were thrown away) and that the
314314
result is inexact (some of the discarded digits were non-zero).
315315

@@ -369,7 +369,7 @@ Decimal objects
369369
with the fullwidth digits ``'\uff10'`` through ``'\uff19'``.
370370

371371
If *value* is a :class:`tuple`, it should have three components, a sign
372-
(:const:`!0` for positive or :const:`!1` for negative), a :class:`tuple` of
372+
(``0`` for positive or ``1`` for negative), a :class:`tuple` of
373373
digits, and an integer exponent. For example, ``Decimal((0, (1, 4, 1, 4), -3))``
374374
returns ``Decimal('1.414')``.
375375

@@ -387,7 +387,7 @@ Decimal objects
387387
The purpose of the *context* argument is determining what to do if *value* is a
388388
malformed string. If the context traps :const:`InvalidOperation`, an exception
389389
is raised; otherwise, the constructor returns a new Decimal with the value of
390-
:const:`!NaN`.
390+
``NaN``.
391391

392392
Once constructed, :class:`Decimal` objects are immutable.
393393

@@ -701,7 +701,7 @@ Decimal objects
701701
.. method:: max(other, context=None)
702702

703703
Like ``max(self, other)`` except that the context rounding rule is applied
704-
before returning and that :const:`!NaN` values are either signaled or
704+
before returning and that ``NaN`` values are either signaled or
705705
ignored (depending on the context and whether they are signaling or
706706
quiet).
707707

@@ -713,7 +713,7 @@ Decimal objects
713713
.. method:: min(other, context=None)
714714

715715
Like ``min(self, other)`` except that the context rounding rule is applied
716-
before returning and that :const:`!NaN` values are either signaled or
716+
before returning and that ``NaN`` values are either signaled or
717717
ignored (depending on the context and whether they are signaling or
718718
quiet).
719719

@@ -830,7 +830,7 @@ Decimal objects
830830
.. method:: same_quantum(other, context=None)
831831

832832
Test whether self and other have the same exponent or whether both are
833-
:const:`!NaN`.
833+
``NaN``.
834834

835835
This operation is unaffected by context and is quiet: no flags are changed
836836
and no rounding is performed. As an exception, the C version may raise
@@ -896,7 +896,7 @@ The :meth:`~Decimal.logical_and`, :meth:`~Decimal.logical_invert`, :meth:`~Decim
896896
and :meth:`~Decimal.logical_xor` methods expect their arguments to be *logical
897897
operands*. A *logical operand* is a :class:`Decimal` instance whose
898898
exponent and sign are both zero, and whose digits are all either
899-
:const:`!0` or :const:`!1`.
899+
``0`` or ``1``.
900900

901901
.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
902902
@@ -982,7 +982,7 @@ described below. In addition, the module provides three pre-made contexts:
982982
exceptions are not raised during computations).
983983

984984
Because the traps are disabled, this context is useful for applications that
985-
prefer to have result value of :const:`!NaN` or :const:`!Infinity` instead of
985+
prefer to have result value of ``NaN`` or ``Infinity`` instead of
986986
raising exceptions. This allows an application to complete a run in the
987987
presence of conditions that would otherwise halt the program.
988988

@@ -1016,7 +1016,7 @@ In addition to the three supplied contexts, new contexts can be created with the
10161016
default values are copied from the :const:`DefaultContext`. If the *flags*
10171017
field is not specified or is :const:`None`, all flags are cleared.
10181018

1019-
*prec* is an integer in the range [:const:`!1`, :const:`MAX_PREC`] that sets
1019+
*prec* is an integer in the range [``1``, :const:`MAX_PREC`] that sets
10201020
the precision for arithmetic operations in the context.
10211021

10221022
The *rounding* option is one of the constants listed in the section
@@ -1026,20 +1026,20 @@ In addition to the three supplied contexts, new contexts can be created with the
10261026
contexts should only set traps and leave the flags clear.
10271027

10281028
The *Emin* and *Emax* fields are integers specifying the outer limits allowable
1029-
for exponents. *Emin* must be in the range [:const:`MIN_EMIN`, :const:`!0`],
1030-
*Emax* in the range [:const:`!0`, :const:`MAX_EMAX`].
1029+
for exponents. *Emin* must be in the range [:const:`MIN_EMIN`, ``0``],
1030+
*Emax* in the range [``0``, :const:`MAX_EMAX`].
10311031

1032-
The *capitals* field is either :const:`!0` or :const:`!1` (the default). If set to
1033-
:const:`!1`, exponents are printed with a capital :const:`!E`; otherwise, a
1034-
lowercase :const:`!e` is used: :const:`!Decimal('6.02e+23')`.
1032+
The *capitals* field is either ``0`` or ``1`` (the default). If set to
1033+
``1``, exponents are printed with a capital ``E``; otherwise, a
1034+
lowercase ``e`` is used: ``Decimal('6.02e+23')``.
10351035

1036-
The *clamp* field is either :const:`!0` (the default) or :const:`!1`.
1037-
If set to :const:`!1`, the exponent ``e`` of a :class:`Decimal`
1036+
The *clamp* field is either ``0`` (the default) or ``1``.
1037+
If set to ``1``, the exponent ``e`` of a :class:`Decimal`
10381038
instance representable in this context is strictly limited to the
10391039
range ``Emin - prec + 1 <= e <= Emax - prec + 1``. If *clamp* is
1040-
:const:`!0` then a weaker condition holds: the adjusted exponent of
1040+
``0`` then a weaker condition holds: the adjusted exponent of
10411041
the :class:`Decimal` instance is at most ``Emax``. When *clamp* is
1042-
:const:`!1`, a large normal number will, where possible, have its
1042+
``1``, a large normal number will, where possible, have its
10431043
exponent reduced and a corresponding number of zeros added to its
10441044
coefficient, in order to fit the exponent constraints; this
10451045
preserves the value of the number but loses information about
@@ -1048,7 +1048,7 @@ In addition to the three supplied contexts, new contexts can be created with the
10481048
>>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
10491049
Decimal('1.23000E+999')
10501050

1051-
A *clamp* value of :const:`!1` allows compatibility with the
1051+
A *clamp* value of ``1`` allows compatibility with the
10521052
fixed-width decimal interchange formats specified in IEEE 754.
10531053

10541054
The :class:`Context` class defines several general purpose methods as well as
@@ -1064,11 +1064,11 @@ In addition to the three supplied contexts, new contexts can be created with the
10641064

10651065
.. method:: clear_flags()
10661066

1067-
Resets all of the flags to :const:`!0`.
1067+
Resets all of the flags to ``0``.
10681068

10691069
.. method:: clear_traps()
10701070

1071-
Resets all of the traps to :const:`!0`.
1071+
Resets all of the traps to ``0``.
10721072

10731073
.. versionadded:: 3.3
10741074

@@ -1480,17 +1480,17 @@ Constants
14801480
The constants in this section are only relevant for the C module. They
14811481
are also included in the pure Python version for compatibility.
14821482

1483-
+---------------------+----------------------+--------------------------------+
1484-
| | 32-bit | 64-bit |
1485-
+=====================+======================+================================+
1486-
| .. data:: MAX_PREC | :const:`!425000000` | :const:`!999999999999999999` |
1487-
+---------------------+----------------------+--------------------------------+
1488-
| .. data:: MAX_EMAX | :const:`!425000000` | :const:`!999999999999999999` |
1489-
+---------------------+----------------------+--------------------------------+
1490-
| .. data:: MIN_EMIN | :const:`!-425000000` | :const:`!-999999999999999999` |
1491-
+---------------------+----------------------+--------------------------------+
1492-
| .. data:: MIN_ETINY | :const:`!-849999999` | :const:`!-1999999999999999997` |
1493-
+---------------------+----------------------+--------------------------------+
1483+
+---------------------+---------------------+-------------------------------+
1484+
| | 32-bit | 64-bit |
1485+
+=====================+=====================+===============================+
1486+
| .. data:: MAX_PREC | ``425000000`` | ``999999999999999999`` |
1487+
+---------------------+---------------------+-------------------------------+
1488+
| .. data:: MAX_EMAX | ``425000000`` | ``999999999999999999`` |
1489+
+---------------------+---------------------+-------------------------------+
1490+
| .. data:: MIN_EMIN | ``-425000000`` | ``-999999999999999999`` |
1491+
+---------------------+---------------------+-------------------------------+
1492+
| .. data:: MIN_ETINY | ``-849999999`` | ``-1999999999999999997`` |
1493+
+---------------------+---------------------+-------------------------------+
14941494

14951495

14961496
.. data:: HAVE_THREADS
@@ -1514,15 +1514,15 @@ Rounding modes
15141514

15151515
.. data:: ROUND_CEILING
15161516

1517-
Round towards :const:`!Infinity`.
1517+
Round towards ``Infinity``.
15181518

15191519
.. data:: ROUND_DOWN
15201520

15211521
Round towards zero.
15221522

15231523
.. data:: ROUND_FLOOR
15241524

1525-
Round towards :const:`!-Infinity`.
1525+
Round towards ``-Infinity``.
15261526

15271527
.. data:: ROUND_HALF_DOWN
15281528

@@ -1584,8 +1584,8 @@ condition.
15841584
Signals the division of a non-infinite number by zero.
15851585

15861586
Can occur with division, modulo division, or when raising a number to a negative
1587-
power. If this signal is not trapped, returns :const:`!Infinity` or
1588-
:const:`!-Infinity` with the sign determined by the inputs to the calculation.
1587+
power. If this signal is not trapped, returns ``Infinity`` or
1588+
``-Infinity`` with the sign determined by the inputs to the calculation.
15891589

15901590

15911591
.. class:: Inexact
@@ -1602,7 +1602,7 @@ condition.
16021602
An invalid operation was performed.
16031603

16041604
Indicates that an operation was requested that does not make sense. If not
1605-
trapped, returns :const:`!NaN`. Possible causes include::
1605+
trapped, returns ``NaN``. Possible causes include::
16061606

16071607
Infinity - Infinity
16081608
0 * Infinity
@@ -1622,7 +1622,7 @@ condition.
16221622
Indicates the exponent is larger than :attr:`!Emax` after rounding has
16231623
occurred. If not trapped, the result depends on the rounding mode, either
16241624
pulling inward to the largest representable finite number or rounding outward
1625-
to :const:`!Infinity`. In either case, :class:`Inexact` and :class:`Rounded`
1625+
to ``Infinity``. In either case, :class:`Inexact` and :class:`Rounded`
16261626
are also signaled.
16271627

16281628

@@ -1631,7 +1631,7 @@ condition.
16311631
Rounding occurred though possibly no information was lost.
16321632

16331633
Signaled whenever rounding discards digits; even if those digits are zero
1634-
(such as rounding :const:`!5.00` to :const:`!5.0`). If not trapped, returns
1634+
(such as rounding ``5.00`` to ``5.0``). If not trapped, returns
16351635
the result unchanged. This signal is used to detect loss of significant
16361636
digits.
16371637

@@ -1696,7 +1696,7 @@ Mitigating round-off error with increased precision
16961696
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16971697

16981698
The use of decimal floating point eliminates decimal representation error
1699-
(making it possible to represent :const:`!0.1` exactly); however, some operations
1699+
(making it possible to represent ``0.1`` exactly); however, some operations
17001700
can still incur round-off error when non-zero digits exceed the fixed precision.
17011701

17021702
The effects of round-off error can be amplified by the addition or subtraction
@@ -1746,8 +1746,8 @@ Special values
17461746
^^^^^^^^^^^^^^
17471747

17481748
The number system for the :mod:`decimal` module provides special values
1749-
including :const:`!NaN`, :const:`!sNaN`, :const:`!-Infinity`, :const:`!Infinity`,
1750-
and two zeros, :const:`!+0` and :const:`!-0`.
1749+
including ``NaN``, ``sNaN``, ``-Infinity``, ``Infinity``,
1750+
and two zeros, ``+0`` and ``-0``.
17511751

17521752
Infinities can be constructed directly with: ``Decimal('Infinity')``. Also,
17531753
they can arise from dividing by zero when the :exc:`DivisionByZero` signal is
@@ -1758,28 +1758,28 @@ The infinities are signed (affine) and can be used in arithmetic operations
17581758
where they get treated as very large, indeterminate numbers. For instance,
17591759
adding a constant to infinity gives another infinite result.
17601760

1761-
Some operations are indeterminate and return :const:`!NaN`, or if the
1761+
Some operations are indeterminate and return ``NaN``, or if the
17621762
:exc:`InvalidOperation` signal is trapped, raise an exception. For example,
1763-
``0/0`` returns :const:`!NaN` which means "not a number". This variety of
1764-
:const:`!NaN` is quiet and, once created, will flow through other computations
1765-
always resulting in another :const:`!NaN`. This behavior can be useful for a
1763+
``0/0`` returns ``NaN`` which means "not a number". This variety of
1764+
``NaN`` is quiet and, once created, will flow through other computations
1765+
always resulting in another ``NaN``. This behavior can be useful for a
17661766
series of computations that occasionally have missing inputs --- it allows the
17671767
calculation to proceed while flagging specific results as invalid.
17681768

1769-
A variant is :const:`!sNaN` which signals rather than remaining quiet after every
1769+
A variant is ``sNaN`` which signals rather than remaining quiet after every
17701770
operation. This is a useful return value when an invalid result needs to
17711771
interrupt a calculation for special handling.
17721772

17731773
The behavior of Python's comparison operators can be a little surprising where a
1774-
:const:`!NaN` is involved. A test for equality where one of the operands is a
1775-
quiet or signaling :const:`!NaN` always returns :const:`False` (even when doing
1774+
``NaN`` is involved. A test for equality where one of the operands is a
1775+
quiet or signaling ``NaN`` always returns :const:`False` (even when doing
17761776
``Decimal('NaN')==Decimal('NaN')``), while a test for inequality always returns
17771777
:const:`True`. An attempt to compare two Decimals using any of the ``<``,
17781778
``<=``, ``>`` or ``>=`` operators will raise the :exc:`InvalidOperation` signal
1779-
if either operand is a :const:`!NaN`, and return :const:`False` if this signal is
1779+
if either operand is a ``NaN``, and return :const:`False` if this signal is
17801780
not trapped. Note that the General Decimal Arithmetic specification does not
17811781
specify the behavior of direct comparisons; these rules for comparisons
1782-
involving a :const:`!NaN` were taken from the IEEE 854 standard (see Table 3 in
1782+
involving a ``NaN`` were taken from the IEEE 854 standard (see Table 3 in
17831783
section 5.7). To ensure strict standards-compliance, use the :meth:`~Decimal.compare`
17841784
and :meth:`~Decimal.compare_signal` methods instead.
17851785

@@ -2066,8 +2066,8 @@ to handle the :meth:`~Decimal.quantize` step:
20662066
>>> div(b, a)
20672067
Decimal('0.03')
20682068

2069-
Q. There are many ways to express the same value. The numbers :const:`!200`,
2070-
:const:`!200.000`, :const:`!2E2`, and :const:`!.02E+4` all have the same value at
2069+
Q. There are many ways to express the same value. The numbers ``200``,
2070+
``200.000``, ``2E2``, and ``.02E+4`` all have the same value at
20712071
various precisions. Is there a way to transform them to a single recognizable
20722072
canonical value?
20732073

@@ -2083,7 +2083,7 @@ to get a non-exponential representation?
20832083

20842084
A. For some values, exponential notation is the only way to express the number
20852085
of significant places in the coefficient. For example, expressing
2086-
:const:`!5.0E+3` as :const:`!5000` keeps the value constant but cannot show the
2086+
``5.0E+3`` as ``5000`` keeps the value constant but cannot show the
20872087
original's two-place significance.
20882088

20892089
If an application does not care about tracking significance, it is easy to

0 commit comments

Comments
 (0)