Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5a55b61a
Commit
5a55b61a
authored
Jun 28, 2009
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #6354: More fixes for code examples involving the repr of a float.
parent
6e6565b6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
13 deletions
+13
-13
Doc/library/math.rst
Doc/library/math.rst
+1
-1
Doc/library/sqlite3.rst
Doc/library/sqlite3.rst
+2
-2
Doc/library/turtle.rst
Doc/library/turtle.rst
+1
-1
Doc/tutorial/inputoutput.rst
Doc/tutorial/inputoutput.rst
+4
-4
Doc/tutorial/introduction.rst
Doc/tutorial/introduction.rst
+1
-1
Doc/tutorial/stdlib2.rst
Doc/tutorial/stdlib2.rst
+4
-4
No files found.
Doc/library/math.rst
View file @
5a55b61a
...
...
@@ -82,7 +82,7 @@ Number-theoretic and representation functions
loss of precision by tracking multiple intermediate partial sums::
>>> sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
0.999999999999999
8
9
0.9999999999999999
>>> fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1])
1.0
...
...
Doc/library/sqlite3.rst
View file @
5a55b61a
...
...
@@ -81,7 +81,7 @@ This example uses the iterator form::
>>> for row in c:
... print(row)
...
(u'2006-01-05', u'BUY', u'RHAT', 100, 35.14
0000000000001
)
(u'2006-01-05', u'BUY', u'RHAT', 100, 35.14)
(u'2006-03-28', u'BUY', u'IBM', 1000, 45.0)
(u'2006-04-06', u'SELL', u'IBM', 500, 53.0)
(u'2006-04-05', u'BUY', u'MSOFT', 1000, 72.0)
...
...
@@ -591,7 +591,7 @@ Now we plug :class:`Row` in::
>>> type(r)
<type 'sqlite3.Row'>
>>> r
(u'2006-01-05', u'BUY', u'RHAT', 100.0, 35.14
0000000000001
)
(u'2006-01-05', u'BUY', u'RHAT', 100.0, 35.14)
>>> len(r)
5
>>> r[2]
...
...
Doc/library/turtle.rst
View file @
5a55b61a
...
...
@@ -881,7 +881,7 @@ Color control
>>> tup = (0.2, 0.8, 0.55)
>>> turtle.pencolor(tup)
>>> turtle.pencolor()
(0.2
0000000000000001, 0.80000000000000004
, 0.5490196078431373)
(0.2
, 0.8
, 0.5490196078431373)
>>> colormode(255)
>>> turtle.pencolor()
(51, 204, 140)
...
...
Doc/tutorial/inputoutput.rst
View file @
5a55b61a
...
...
@@ -52,10 +52,10 @@ Some examples::
'Hello, world.'
>>> repr(s)
"'Hello, world.'"
>>> str(
0.1
)
'0.1'
>>> repr(
0.1
)
'0.1
0000000000000001
'
>>> str(
1.0/7.0
)
'0.1
42857142857
'
>>> repr(
1.0/7.0
)
'0.1
4285714285714285
'
>>> x = 10 * 3.25
>>> y = 200 * 200
>>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'
...
...
Doc/tutorial/introduction.rst
View file @
5a55b61a
...
...
@@ -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.6
000000000000001
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
...
...
Doc/tutorial/stdlib2.rst
View file @
5a55b61a
...
...
@@ -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.73
499999999999999
>>>
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment