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.

classification
Title: Float number comparision problem
Type: behavior Stage:
Components: Interpreter Core, Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, tsxy
Priority: normal Keywords:

Created on 2008-02-12 05:36 by tsxy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg62306 - (view) Author: will (tsxy) Date: 2008-02-12 05:36
c=22.99*5.0
print c==114.95
"""This will produce false"""

c=22.99*4.0
print c==91.96
"""This will produce true"""

"""This is not expected behavior for python"""
msg62307 - (view) Author: will (tsxy) Date: 2008-02-12 05:37
The issue is reproduced under WIN32, version info as follows:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit 
(Intel)] on win32
msg62308 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-02-12 08:11
This is expected behavior. Please see 
http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate
History
Date User Action Args
2022-04-11 14:56:30adminsetgithub: 46347
2008-02-12 08:11:23amaury.forgeotdarcsetstatus: open -> closed
resolution: not a bug
messages: + msg62308
nosy: + amaury.forgeotdarc
2008-02-12 05:37:23tsxysetmessages: + msg62307
2008-02-12 05:36:03tsxycreate