Eryk Sun added the comment: > -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. ---------- nosy: +eryksun resolution: rejected -> not a bug status: open -> closed type: crash -> behavior versions: -Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29815> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com