- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
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, priska |
| Date | 2015-06-07.11:51:34 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1433677894.6.0.894860364466.issue24403@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
|---|
This is a bit tricky. The first expression you suggest doesn't work at all for negative numbers (e.g., producing `-3.0` for `round(-1.8)`). The second expression *mostly* works as you want, but not entirely. Some examples: >>> def f(n): return float(math.trunc(n + math.copysign(0.5, n))) ... >>> x = 0.5 - 2**-54 >>> x 0.49999999999999994 >>> f(x) # should be 0.0 1.0 >>> x = 5e15 + 3.0 >>> x 5000000000000003.0 >>> f(x) # should be x again 5000000000000004.0 And neither of these addresses the two-argument case of `round`. It may be better to simply flag this as something that 2to3 can't handle, and that needs a manual check. |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2015-06-07 11:51:34 | mark.dickinson | set | recipients: + mark.dickinson, priska |
| 2015-06-07 11:51:34 | mark.dickinson | set | messageid: <1433677894.6.0.894860364466.issue24403@psf.upfronthosting.co.za> |
| 2015-06-07 11:51:34 | mark.dickinson | link | issue24403 messages |
| 2015-06-07 11:51:34 | mark.dickinson | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
