File tree Expand file tree Collapse file tree 1 file changed +2
-17
lines changed
Expand file tree Collapse file tree 1 file changed +2
-17
lines changed Original file line number Diff line number Diff line change @@ -108,23 +108,8 @@ reproduce *x*, but the output may be more pleasant to look at::
108108It's important to realize that this is, in a real sense, an illusion: you're
109109simply 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):
You can’t perform that action at this time.
0 commit comments