[ python-Bugs-1355903 ] Division Error

SourceForge.net noreply at sourceforge.net
Sun Nov 13 16:52:07 CET 2005


Bugs item #1355903, was opened at 2005-11-13 15:41
Message generated for change (Comment added) made by effbot
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1355903&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Azimuth (azimuth84)
Assigned to: Nobody/Anonymous (nobody)
Summary: Division Error

Initial Comment:
The division operation "7.0/5" yields 1.399999 instead
of 1.4

----------------------------------------------------------------------

Comment By: Fredrik Lundh (effbot)
Date: 2005-11-13 16:52

Message:
Logged In: YES 
user_id=38376

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

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1355903&group_id=5470


More information about the Python-bugs-list mailing list