Fix some documentation examples involving the repr of a float.
diff --git a/Doc/tutorial/floatingpoint.rst b/Doc/tutorial/floatingpoint.rst
index 29c7a66..3554e4f 100644
--- a/Doc/tutorial/floatingpoint.rst
+++ b/Doc/tutorial/floatingpoint.rst
@@ -115,7 +115,7 @@
... sum += 0.1
...
>>> sum
- 0.99999999999999989
+ 0.9999999999999999
Binary floating-point arithmetic holds many surprises like this. The problem
with "0.1" is explained in precise detail below, in the "Representation Error"
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index 0259749..8d23cc1 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -49,10 +49,10 @@
'Hello, world.'
>>> repr(s)
"'Hello, world.'"
- >>> str(0.1)
- '0.1'
- >>> repr(0.1)
- '0.10000000000000001'
+ >>> str(1.0/7.0)
+ '0.142857142857'
+ >>> repr(1.0/7.0)
+ '0.14285714285714285'
>>> x = 10 * 3.25
>>> y = 200 * 200
>>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index 0197a6f..4ae85b1 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -362,10 +362,13 @@
becomes significant if the results are rounded to the nearest cent::
>>> from decimal import *
- >>> Decimal('0.70') * Decimal('1.05')
+ >>> x = Decimal('0.70') * Decimal('1.05')
+ >>> x
Decimal('0.7350')
- >>> .70 * 1.05
- 0.73499999999999999
+ >>> x.quantize(Decimal('0.01')) # round to nearest cent
+ Decimal('0.74')
+ >>> round(.70 * 1.05, 2) # same calculation with floats
+ 0.73
The :class:`Decimal` result keeps a trailing zero, automatically inferring four
place significance from multiplicands with two place significance. Decimal