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: python 3.8.1 (3.14 * 10 = 31.400000002 bug)
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: steven.daprano, xtreak, 꿈돌
Priority: normal Keywords:

Created on 2020-02-25 13:24 by 꿈돌, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg362641 - (view) Author: 꿈돌 (꿈돌) Date: 2020-02-25 13:24
10 * 3.14
31.400000000000002

there is a bug in 3.8.1 python, 10 * 3.14 is 31.4 but in python 31.400000000000002....
msg362642 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-02-25 13:28
This is a known behavior : https://docs.python.org/3/tutorial/floatingpoint.html
msg362647 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2020-02-25 15:38
This behaviour is shared by all programming languages that use floating point numbers. For example, this is Ruby:

    [steve@ando ~]$ irb
    irb(main):001:0> 10 * 3.14 == 31.4
    => false
    irb(main):002:0> 10 * 3.14 - 31.4
    => 3.5527136788005e-15

It's not a bug in Python or even in floating point numbers. See the link in the tutorial that xtreak gave and the FAQ

https://docs.python.org/3/faq/design.html#why-am-i-getting-strange-results-with-simple-arithmetic-operations
History
Date User Action Args
2022-04-11 14:59:27adminsetgithub: 83930
2020-02-25 15:38:20steven.dapranosetstatus: open -> closed

nosy: + steven.daprano
messages: + msg362647

resolution: not a bug
stage: resolved
2020-02-25 13:28:33xtreaksetnosy: + xtreak
messages: + msg362642
2020-02-25 13:24:53꿈돌create