New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
g formatting for decimal types should always strip trailing zeros. #51347
Comments
Type 'g' formatting for Decimal instances doesn't behave in the same way 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' |
Here's a patch for trunk. |
Hmm. Thinking about this some more, I don't think this is true: format() shouldn't be throwing away significant information (in Decimal So I think the current code is correct. However, we could do with documenting the precise rules being used for |
I would like to think about this one for a bit before it moves forward. |
[Mark]
I agree with this. Currently the 'g' format is like to_sci_string() |
Closing as invalid. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: