Am 26.08.16 um 09:53 schrieb Erik:
On 26/08/16 08:44, mlzarathus...@gmail.com wrote:
Here's the key:
$ python2
Python 2.7.10 ...
1/2
0
$ python
Python 3.5.1 ...
1/2
0.5
1//2
0
I read about this awhile ago, but it's not until it bites you that you
remember fully.
How is this related to your question? The example explicitly says Python
2 and doesn't use the '//' operator.
It's related by the fact that a*b/c performs integer division (intended
by the OP) which gives a different result than a*(b/c) (unintended by
the OP). Floating point (as in Python 3) *also* may give a different
result, but the deviation from the "true", i.e. mathematical value, is
far less than with integer arithmetics.
Christian
--
https://mail.python.org/mailman/listinfo/python-list