classification
Title: Basic subtraction is wrong ( 1.83 - 1.52 == 0.31000000000000005)
Type: Stage: resolved
Components: Versions: Python 3.7, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: René Podlogar, mark.dickinson
Priority: normal Keywords:

Created on 2017-06-25 09:14 by René Podlogar, last changed 2017-06-25 09:44 by mark.dickinson. This issue is now closed.

Messages (2)
msg296817 - (view) Author: René Podlogar (René Podlogar) Date: 2017-06-25 09:14
My Python-Installations Python 2.7.12, Python 3.4.5 @linux64
and the CLI on the python.org-Website (interactive shell) affected:

Python 3.6.0 (default, Jan 13 2017, 00:00:00) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1.83 - 1.52
0.31000000000000005
>>> 

Expected= 0.31

Verified in irc-channel #python.de
msg296818 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2017-06-25 09:44
This is working as expected. Python's floats use the hardware-provided _binary_ floating-point format, which can't represent every finite decimal value exactly. I recommend reading https://docs.python.org/3.6/tutorial/floatingpoint.html for more information.
History
Date User Action Args
2017-06-25 09:44:13mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg296818

resolution: not a bug
stage: resolved
2017-06-25 09:14:37René Podlogarcreate