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: subtraction of pennies incorrect rounding or truncation problem
Type: behavior Stage: resolved
Components: Windows Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: radiokinetics.pete, tim.peters
Priority: normal Keywords:

Created on 2013-10-16 05:09 by radiokinetics.pete, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py_subtraction_bug radiokinetics.pete, 2013-10-16 05:09 txt
Messages (2)
msg200035 - (view) Author: Pete (radiokinetics.pete) Date: 2013-10-16 05:09
Python makes errors on simple subtraction with 'pennies'. 
>>> 2000.0 - 1880.98
119.01999999999998

See attached file for more examples...
msg200036 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2013-10-16 05:14
Please read this:

http://docs.python.org/2/tutorial/floatingpoint.html

A web search will lead you to thousands of discussions of alternatives.  Probably best to use the `decimal` module if you're working heavily with decimal values.
History
Date User Action Args
2022-04-11 14:57:52adminsetgithub: 63468
2013-10-16 05:14:21tim.peterssetstatus: open -> closed

nosy: + tim.peters
messages: + msg200036

resolution: not a bug
stage: resolved
2013-10-16 05:09:20radiokinetics.petecreate