Message93835
Type 'g' formatting for Decimal instances doesn't behave in the same way
as for floats when an explicit precision is given. It should strip all
trailing zeros from the result:
Python 2.7a0 (trunk:75309, Oct 10 2009, 13:44:18)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import Decimal
>>> format(Decimal('123.00'), '.6g') # expect '123'
'123.00'
(When no explicit precision is given, Decimal formatting with type 'g'
tries to preserve the information about the exponent of the Decimal
instance whenever possible; this also differs from float formatting, but
it's intentional. This should probably be documented.) |
|
Date |
User |
Action |
Args |
2009-10-10 18:22:12 | mark.dickinson | set | recipients:
+ mark.dickinson |
2009-10-10 18:22:12 | mark.dickinson | set | messageid: <1255198932.03.0.979291900289.issue7098@psf.upfronthosting.co.za> |
2009-10-10 18:22:10 | mark.dickinson | link | issue7098 messages |
2009-10-10 18:22:10 | mark.dickinson | create | |
|