Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Math Division Problem? #40052

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

Closed
grasp81 mannequin opened this issue Mar 19, 2004 · 2 comments
Closed

Math Division Problem? #40052

grasp81 mannequin opened this issue Mar 19, 2004 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@grasp81
Copy link
Mannequin

grasp81 mannequin commented Mar 19, 2004

BPO 919498
Nosy @sjoerdmullender

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 = None
closed_at = <Date 2004-03-19.14:23:05.000>
created_at = <Date 2004-03-19.13:20:25.000>
labels = ['interpreter-core', 'invalid']
title = 'Math Division Problem?'
updated_at = <Date 2004-03-19.14:23:05.000>
user = 'https://bugs.python.org/grasp81'

bugs.python.org fields:

activity = <Date 2004-03-19.14:23:05.000>
actor = 'sjoerd'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Interpreter Core']
creation = <Date 2004-03-19.13:20:25.000>
creator = 'grasp81'
dependencies = []
files = []
hgrepos = []
issue_num = 919498
keywords = []
message_count = 2.0
messages = ['20270', '20271']
nosy_count = 2.0
nosy_names = ['sjoerd', 'grasp81']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue919498'
versions = ['Python 2.3']

@grasp81
Copy link
Mannequin Author

grasp81 mannequin commented Mar 19, 2004

Using
Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC
v.1200 32 bit (Intel)] on win32

A mere real division resulted in this:
>>> 7.0/3
2.3333333333333335

Mind the trailing '5'. Did I miss my University classes too
much? ;)

Amazingly,
>>> 4.0/3
1.3333333333333333
- works OK.

@grasp81 grasp81 mannequin closed this as completed Mar 19, 2004
@grasp81 grasp81 mannequin added invalid interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 19, 2004
@grasp81 grasp81 mannequin closed this as completed Mar 19, 2004
@grasp81 grasp81 mannequin added invalid interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Mar 19, 2004
@sjoerdmullender
Copy link
Member

Logged In: YES
user_id=43607

This is not a bug.

Binary floating point cannot represent decimal fractions exactly,
so some rounding always occurs (even in Python 1.5.2).

What changed is that Python 2.0 shows more precision than before
in certain circumstances (repr() and the interactive prompt).

You can use str() or print to get the old, rounded output:

>>> print 0.1+0.1
0.2
>>>

Follow the link for more information:

http://www.python.org/doc/2.2.1/tut/node14.html

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

1 participant