[issue33372] Wrong calculation

Tim Peters report at bugs.python.org
Fri Apr 27 01:44:29 EDT 2018


Tim Peters <tim at python.org> added the comment:

Please find a minimal example that illustrates the problem you think you've found, and paste the plain text _into_ the bug report.

In the meantime, I'm closing this as "not a bug".  The division operator applied to integers in Python 2 defaults doing truncating integer division, and in Python 3 defaults to doing floating point division instead.  So this example all by itself is enough to show a difference:

Under Python 2.7.11:

>>> 1/8
0

Under Python 3.6.5:

>>> 1/8
0.125

Both are expected.

In exactly the same way, the subexpression "2*1*10/100*10*10+100/10" in the code you pasted returns the integer 10 under Python 2 but the floating point value 30.0 under Python 3.

----------
nosy: +tim.peters
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33372>
_______________________________________


More information about the Python-bugs-list mailing list