summaryrefslogtreecommitdiffstats
path: root/Doc/tutorial
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-06-28 21:00:42 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-06-28 21:00:42 (GMT)
commitd1cc39d3d833289e924c8ded75f6cc94dc4cc5a5 (patch)
treeb72027a1669d3bf7c166535e42dafae1107a7921 /Doc/tutorial
parentcf2d9ff3c5f84eb0481165167b1c523d568ecf7b (diff)
downloadcpython-d1cc39d3d833289e924c8ded75f6cc94dc4cc5a5.zip
cpython-d1cc39d3d833289e924c8ded75f6cc94dc4cc5a5.tar.gz
cpython-d1cc39d3d833289e924c8ded75f6cc94dc4cc5a5.tar.bz2
Merged revisions 73636 via svnmerge from
svn+ssh://pythondev@www.python.org/python/branches/py3k ........ r73636 | mark.dickinson | 2009-06-28 21:59:42 +0100 (Sun, 28 Jun 2009) | 2 lines Issue #6354: More fixes for code examples involving the repr of a float. ........
Diffstat (limited to 'Doc/tutorial')
-rw-r--r--Doc/tutorial/inputoutput.rst8
-rw-r--r--Doc/tutorial/introduction.rst2
-rw-r--r--Doc/tutorial/stdlib2.rst8
3 files changed, 9 insertions, 9 deletions
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index eabf662..b1efd1a 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -52,10 +52,10 @@ Some examples::
'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/introduction.rst b/Doc/tutorial/introduction.rst
index 3757fc3..1b3faae 100644
--- a/Doc/tutorial/introduction.rst
+++ b/Doc/tutorial/introduction.rst
@@ -56,7 +56,7 @@ operators ``+``, ``-``, ``*`` and ``/`` work just like in most other languages
>>> (50-5*6)/4
5.0
>>> 8/5 # Fractions aren't lost when dividing integers
- 1.6000000000000001
+ 1.6
Note: You might not see exactly the same result; floating point results can
differ from one machine to another. We will say more later about controlling
diff --git a/Doc/tutorial/stdlib2.rst b/Doc/tutorial/stdlib2.rst
index 4be3275..d17b031 100644
--- a/Doc/tutorial/stdlib2.rst
+++ b/Doc/tutorial/stdlib2.rst
@@ -359,10 +359,10 @@ results in decimal floating point and binary floating point. The difference
becomes significant if the results are rounded to the nearest cent::
>>> from decimal import *
- >>> Decimal('0.70') * Decimal('1.05')
- Decimal("0.7350")
- >>> .70 * 1.05
- 0.73499999999999999
+ >>> round(Decimal('0.70') * Decimal('1.05'), 2)
+ Decimal('0.74')
+ >>> round(.70 * 1.05, 2)
+ 0.73
The :class:`Decimal` result keeps a trailing zero, automatically inferring four
place significance from multiplicands with two place significance. Decimal