Title: Issue with Round Function in Python · Issue #123811 · python/cpython · GitHub
Open Graph Title: Issue with Round Function in Python · Issue #123811 · python/cpython
X Title: Issue with Round Function in Python · Issue #123811 · python/cpython
Description: Bug report Bug description: Description of the Issue: The round function does not seem to handle certain floating-point numbers correctly. For example, when rounding the number -1357.1357 to negative 4 decimal places, the function return...
Open Graph Description: Bug report Bug description: Description of the Issue: The round function does not seem to handle certain floating-point numbers correctly. For example, when rounding the number -1357.1357 to negati...
X Description: Bug report Bug description: Description of the Issue: The round function does not seem to handle certain floating-point numbers correctly. For example, when rounding the number -1357.1357 to negati...
Opengraph URL: https://github.com/python/cpython/issues/123811
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":" Issue with Round Function in Python","articleBody":"# Bug report\n\n### Bug description:\n\n**Description of the Issue:**\nThe `round` function does not seem to handle certain floating-point numbers correctly. For example, when rounding the number -1357.1357 to negative 4 decimal places, the function returns -0.0 instead of the expected 0.0.\n\n**Steps to Reproduce:**\n1. Open a Python interpreter.\n2. Execute the following code:\n\n```\nprint(round(-1357.1357, -4))\n```\n\n3. Observe the output.\n\nExpected Result: The output should be 0.0.\nActual Result: The output is -0.0.\n\n**Environment Details Tested:**\n--Python Version: 3.12.5, Operating System: Windows 11.\n--Python Version: 3.12.3, Operating System: Ubuntu.\n\nAdditional Information: I have verified this issue on multiple machines and with different Python versions. The issue persists across all tested environments.\n\n### CPython versions tested on:\n\n3.12, 3.13\n\n### Operating systems tested on:\n\nLinux, Windows\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-123829\n* gh-123938\n* gh-123939\n* gh-124007\n* gh-124048\n* gh-124049\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/lykan89","@type":"Person","name":"lykan89"},"datePublished":"2024-09-07T17:07:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":19},"url":"https://github.com/123811/cpython/issues/123811"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:167fd49f-029f-74fe-628b-4a8273e84ae7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A790:274DA4:6DE708:95624A:6A537241 |
| html-safe-nonce | af1cd9fed7ae24c6cba5eacc28b1dc77a503ed0c8a43030813e26bddeb2f9539 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzkwOjI3NERBNDo2REU3MDg6OTU2MjRBOjZBNTM3MjQxIiwidmlzaXRvcl9pZCI6IjIwNzAzNjE1MjkwOTQ3MzAzMDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d975e8c95cd89be40315a257f7287f415ba49d15f095e62a26e286d77af99fcc |
| hovercard-subject-tag | issue:2511910215 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/123811/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4f94f217696c586fd1e291ba8b20c16dac87e953bae10741dba30bf13f518074/python/cpython/issues/123811 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4f94f217696c586fd1e291ba8b20c16dac87e953bae10741dba30bf13f518074/python/cpython/issues/123811 |
| og:image:alt | Bug report Bug description: Description of the Issue: The round function does not seem to handle certain floating-point numbers correctly. For example, when rounding the number -1357.1357 to negati... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lykan89 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width