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 Aaron.Meurer
Recipients Aaron.Meurer, eric.smith, facundobatista, mark.dickinson, rhettinger, skrah
Date 2017-10-04.18:36:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507142174.41.0.213398074469.issue31684@psf.upfronthosting.co.za>
In-reply-to
Content
I meant that format() destroys information in a decimal in general. Obviously if you have n digits of precision and format with m < n, then you lose information. 

I also can't help but feel that we're mixing up "trailing zeros" (i.e., precision), and "exponent" (magnitude), which should be orthogonal. I'm assuming that a decimal is represented internally as base*10**exponent. I'm also assuming that Decimal(0) sets both base and exponent to 0. It doesn't make sense to me that a string formatting operation that requests a certain number of digits of precision should change the exponent. 

I get that 0.0 is different from 0.00000, but in that case, they should print differently: as '0.0' and '0.00000'. It seems sly to try to maintain that through a format operation via the exponent, especially when format *in general* loses precision information for a decimal anyway (by "format" I mean format with a set number of digits requested). Especially since that "trick" only works for exactly one number, zero. If you do '{:+.30e}'.format(Decimal('1.0000000000000000000')) or '{:+.10e}'.format(Decimal('1.0000000000000000000')), no such trick is used, because no such trick can be used. You just lose information. 

I'm sure my mental model is off here. I'm used to sympy.Float/mpmath.mpf where values like 0*2**i are normalized to i = 0 (e.g. mpmath.mpf((0, 0, 20, 0))._mpf_ gives (0, 0, 0, 0)), so this problem never comes up in the code that I'm used to.
History
Date User Action Args
2017-10-04 18:36:14Aaron.Meurersetrecipients: + Aaron.Meurer, rhettinger, facundobatista, mark.dickinson, eric.smith, skrah
2017-10-04 18:36:14Aaron.Meurersetmessageid: <1507142174.41.0.213398074469.issue31684@psf.upfronthosting.co.za>
2017-10-04 18:36:14Aaron.Meurerlinkissue31684 messages
2017-10-04 18:36:14Aaron.Meurercreate