Skip to content

Commit 0279527

Browse files
committed
📝 Update folating points
1 parent 99d4b68 commit 0279527

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

docs/types/numbers/index.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ The ``math`` module provides, among other things
158158
Rounding half to even
159159
---------------------
160160

161-
Usually Python calculates floating point numbers according to the `IEEE 754
162-
<https://en.wikipedia.org/wiki/IEEE_754>`_ standard, rounding down numbers in
163-
the middle half of the time and rounding up in the other half to avoid
164-
statistical drift in longer calculations. :class:`Decimal
165-
<python3:decimal.Decimal>` and :data:`ROUND_HALF_UP
166-
<python3:decimal.ROUND_HALF_UP>` from the decimal module are therefore needed
167-
for `rounding half to even
168-
<https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even>`_:
161+
Python typically performs floating-point calculations in base 2, whereby numbers
162+
in the middle are rounded down in half the cases and rounded up in the other
163+
half, in order to prevent statistical drift during lengthy calculations.
164+
However, the :class:`Decimal <python3:decimal.Decimal>` class also allows
165+
calculations to be performed in base 10. For commercial rounding,
166+
:data:`ROUND_HALF_UP <python3:decimal.ROUND_HALF_UP>` from the Decimal class
167+
is also required for `rounding half up
168+
<https://en.wikipedia.org/wiki/Rounding#Rounding_half_up>`_:
169169

170170
.. code-block:: pycon
171171
@@ -175,6 +175,9 @@ for `rounding half to even
175175
>>> rounded
176176
Decimal('3')
177177
178+
.. seealso::
179+
* `IEEE 754 <https://en.wikipedia.org/wiki/IEEE_754>`_
180+
178181
Built-in modules for numbers
179182
----------------------------
180183

0 commit comments

Comments
 (0)