[Python-checkins] r71979 - python/branches/py3k/Doc/tutorial/floatingpoint.rst

raymond.hettinger python-checkins at python.org
Sun Apr 26 22:10:50 CEST 2009


Author: raymond.hettinger
Date: Sun Apr 26 22:10:50 2009
New Revision: 71979

Log:
Remove the round() discussion which is now out-of-date.

Modified:
   python/branches/py3k/Doc/tutorial/floatingpoint.rst

Modified: python/branches/py3k/Doc/tutorial/floatingpoint.rst
==============================================================================
--- python/branches/py3k/Doc/tutorial/floatingpoint.rst	(original)
+++ python/branches/py3k/Doc/tutorial/floatingpoint.rst	Sun Apr 26 22:10:50 2009
@@ -108,23 +108,8 @@
 It's important to realize that this is, in a real sense, an illusion: you're
 simply rounding the *display* of the true machine value.
 
-Other surprises follow from this one.  For example, after seeing ::
-
-   >>> format(0.1, '.17g')
-   '0.10000000000000001'
-
-you may be tempted to use the :func:`round` function to chop it back to the
-single digit you expect.  But that makes no difference::
-
-   >>> format(round(0.1, 1), '.17g')
-   '0.10000000000000001'
-
-The problem is that the binary floating-point value stored for "0.1" was already
-the best possible binary approximation to 1/10, so trying to round it again
-can't make it better:  it was already as good as it gets.
-
-Another consequence is that since 0.1 is not exactly 1/10, summing ten values of
-0.1 may not yield exactly 1.0, either::
+One illusion may beget another.  For example, since 0.1 is not exactly 1/10,
+summing ten values of 0.1 may not yield exactly 1.0, either::
 
    >>> sum = 0.0
    >>> for i in range(10):


More information about the Python-checkins mailing list