Message93835
| 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: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 |
|