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: Invalid floating point multiplication result
Type: behavior Stage: resolved
Components: Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: SilentGhost, Tonimore, xtreak
Priority: normal Keywords:

Created on 2019-05-23 11:55 by Tonimore, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg343287 - (view) Author: Antony (Tonimore) Date: 2019-05-23 11:55
Incorrect Multiplication result of number 40.95


>>> 40.94 * 100
4094.0

>>> 40.96 * 100
4096.0

but:
>>> 40.95 * 100
4095.0000000000005

checked with:
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
and
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
msg343288 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-05-23 11:59
This is a limitation of floating points representation. If you need objects representing decimal numeral, you could use decimal module.
msg343289 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-05-23 12:01
Relevant doc : https://docs.python.org/3/tutorial/floatingpoint.html
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81201
2019-05-23 12:01:28xtreaksetnosy: + xtreak
messages: + msg343289
2019-05-23 11:59:40SilentGhostsetstatus: open -> closed

nosy: + SilentGhost
messages: + msg343288

resolution: not a bug
stage: resolved
2019-05-23 11:55:29Tonimorecreate