classification
Title: Floating-point arithmetic
Type: Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: abarry, goodbad
Priority: normal Keywords:

Created on 2016-02-05 02:54 by goodbad, last changed 2016-02-05 03:00 by abarry. This issue is now closed.

Messages (2)
msg259622 - (view) Author: good.bad (goodbad) Date: 2016-02-05 02:54
print(1 - 0.8)
0.19999999999999996
print(1 - 0.2)
0.8

why not 0.2?
msg259623 - (view) Author: Anilyka Barry (abarry) * (Python triager) Date: 2016-02-05 03:00
This is due to how floating point numbers are handled under the hood. See http://effbot.org/pyfaq/why-are-floating-point-calculations-so-inaccurate.htm and https://docs.python.org/3/tutorial/floatingpoint.html for some useful read about why Python behaves like this regarding floating point numbers. Both these link state that this isn't a bug in Python, rightly so as it isn't.
History
Date User Action Args
2016-02-05 03:00:43abarrysetstatus: open -> closed

nosy: + abarry
messages: + msg259623

resolution: not a bug
stage: resolved
2016-02-05 02:54:53goodbadcreate