mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #6354: More fixes for code examples involving the repr of a float.
This commit is contained in:
parent
6e6565b64b
commit
5a55b61a2a
6 changed files with 13 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue