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
ceil(), floor() and round() broken in Decimal #46997
Comments
In Python 3.0, the Decimal __round__, __ceil__ and __floor__ functions This is easy to fix. The only reason I'm making an issue (literally) of Either all three functions should be removed, or they should be |
I remember the answer being that they shouldn't be supported, but then I |
I've removed __round__, __ceil__ and __floor__ in r62669; the code was This still leaves the question of whether to implement these functions. |
Thanks Mark. I'll review your patch when it's ready. |
Here's a patch that implements __ceil__, __floor__ and __round__. (It Points to note: (1) Two-argument round has essentially the same semantics as quantize. round(x, n) is exactly interchangeable with x.quantize(Decimal('1E%s' % -n)) In particular, this means that round uses the rounding mode from the After thinking about it, it seemed better to make the two expressions (2) Decimal.__round__ takes two optional arguments, 'context' and (3) For one-argument round, ceil, and floor, the only real decision to |
The patch basically looks good. The signature for __round__() should |
Here's a revised patch, with the following changes
|
Thanks for the patch. Please apply. |
Thanks for reviewing this, Raymond! Committed, r62938. |
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: