This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients mark.dickinson
Date 2009-10-10.18:22:10
SpamBayes Score 1.4577146e-08
Marked as misclassified No
Message-id <1255198932.03.0.979291900289.issue7098@psf.upfronthosting.co.za>
In-reply-to
Content
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.)
History
Date User Action Args
2009-10-10 18:22:12mark.dickinsonsetrecipients: + mark.dickinson
2009-10-10 18:22:12mark.dickinsonsetmessageid: <1255198932.03.0.979291900289.issue7098@psf.upfronthosting.co.za>
2009-10-10 18:22:10mark.dickinsonlinkissue7098 messages
2009-10-10 18:22:10mark.dickinsoncreate