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: Wrong subtraction calculations
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Svabo, mark.dickinson, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2020-07-10 13:43 by Svabo, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python error.jpg Svabo, 2020-07-10 13:43 example of error
Messages (2)
msg373465 - (view) Author: Ivan (Svabo) Date: 2020-07-10 13:43
I've started to learn python and tried command:
print(-2.989 + 2)
it gives me result of -0.9889999999999999
same error can be observed with numbers from 4 and below like:
print(-2.989 + 4)
1.0110000000000001

print(-2.989 + 3)
0.01100000000000012

print(-2.989 + 1)
-1.9889999999999999

Numbers above 4 seam to work fine
msg373466 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2020-07-10 13:54
Thanks for the report. This isn't a Python bug, but a common issue when working with floating-point numbers.

I recommend taking a look at this section of the tutorial for more information: https://docs.python.org/3.8/tutorial/floatingpoint.html
History
Date User Action Args
2022-04-11 14:59:33adminsetgithub: 85441
2020-07-10 13:54:39mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg373466

resolution: not a bug
stage: resolved
2020-07-10 13:43:09Svabocreate