Skip to content
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

round(x) gives wrong result for large odd integers #51319

Closed
mdickinson opened this issue Oct 6, 2009 · 2 comments
Closed

round(x) gives wrong result for large odd integers #51319

mdickinson opened this issue Oct 6, 2009 · 2 comments
Assignees
Labels
easy type-bug An unexpected behavior, bug, or error

Comments

@mdickinson
Copy link
Member

BPO 7070
Nosy @mdickinson

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:

assignee = 'https://github.com/mdickinson'
closed_at = <Date 2009-11-09.17:46:04.788>
created_at = <Date 2009-10-06.08:38:44.487>
labels = ['easy', 'type-bug']
title = 'round(x) gives wrong result for large odd integers'
updated_at = <Date 2009-11-09.17:46:04.787>
user = 'https://github.com/mdickinson'

bugs.python.org fields:

activity = <Date 2009-11-09.17:46:04.787>
actor = 'mark.dickinson'
assignee = 'mark.dickinson'
closed = True
closed_date = <Date 2009-11-09.17:46:04.788>
closer = 'mark.dickinson'
components = []
creation = <Date 2009-10-06.08:38:44.487>
creator = 'mark.dickinson'
dependencies = []
files = []
hgrepos = []
issue_num = 7070
keywords = ['easy']
message_count = 2.0
messages = ['93635', '95091']
nosy_count = 1.0
nosy_names = ['mark.dickinson']
pr_nums = []
priority = 'high'
resolution = 'fixed'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue7070'
versions = ['Python 2.6']

@mdickinson
Copy link
Member Author

The single-argument form of the builtin round function can give
incorrect results for large integers.

>>> x = 5e15+1
>>> x == int(x)
True
>>> x == round(x)  # expect True here
False
>>> x
5000000000000001.0
>>> round(x)
5000000000000002.0
>>> int(x)
5000000000000001

This is already fixed in trunk (and in 3.x); the fix needs to be
backported to release26-maint.

@mdickinson mdickinson self-assigned this Oct 6, 2009
@mdickinson mdickinson added easy type-bug An unexpected behavior, bug, or error labels Oct 6, 2009
@mdickinson
Copy link
Member Author

Fixed in r76179.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant