Message289665
> -7 divided by 2 is -3, not -4
Integer division in Python is floor division, and it's self-consistent with the implementation of the modulo operation such that the following identity is satisfied: (a % n) == a - n * (a // n). For example:
(-7 % 2) == -7 - 2 * (-7 // 2)
1 == -7 - 2 * (-4)
== -7 + 8
This behavior is consistent with mathematical analysis languages such as MATLAB, Mathematica, Mathcad, and R. It's also consistent with Ruby, Perl, and Tcl. However, it's different from C, C++, C#, Java, PHP and many other languages. See the following Wikipedia article:
https://en.wikipedia.org/wiki/Modulo_operation
Please do not change the status and resolution of this issue again. This is not a bug. |
|
Date |
User |
Action |
Args |
2017-03-15 10:39:48 | eryksun | set | recipients:
+ eryksun, martin.panter, marcosthomazs |
2017-03-15 10:39:48 | eryksun | set | messageid: <1489574388.86.0.574609366091.issue29815@psf.upfronthosting.co.za> |
2017-03-15 10:39:48 | eryksun | link | issue29815 messages |
2017-03-15 10:39:48 | eryksun | create | |
|