Skip to content

Commit f0320c7

Browse files
committed
Remove the round() discussion which is now out-of-date.
1 parent ce95e56 commit f0320c7

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

Doc/tutorial/floatingpoint.rst

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,8 @@ reproduce *x*, but the output may be more pleasant to look at::
108108
It's important to realize that this is, in a real sense, an illusion: you're
109109
simply rounding the *display* of the true machine value.
110110

111-
Other surprises follow from this one. For example, after seeing ::
112-
113-
>>> format(0.1, '.17g')
114-
'0.10000000000000001'
115-
116-
you may be tempted to use the :func:`round` function to chop it back to the
117-
single digit you expect. But that makes no difference::
118-
119-
>>> format(round(0.1, 1), '.17g')
120-
'0.10000000000000001'
121-
122-
The problem is that the binary floating-point value stored for "0.1" was already
123-
the best possible binary approximation to 1/10, so trying to round it again
124-
can't make it better: it was already as good as it gets.
125-
126-
Another consequence is that since 0.1 is not exactly 1/10, summing ten values of
127-
0.1 may not yield exactly 1.0, either::
111+
One illusion may beget another. For example, since 0.1 is not exactly 1/10,
112+
summing ten values of 0.1 may not yield exactly 1.0, either::
128113

129114
>>> sum = 0.0
130115
>>> for i in range(10):

0 commit comments

Comments
 (0)