Delete comment from: The History of Python
For the benefit of those wondering which approach to take for their own programming language, consider that there are cases where the floor integer division doesn't obey the normal rules of algebra as well as truncating integer division; some apparently equivalent expressions will give different results:
-5//2 * -1 == -2, but -1 * -5 // 2 == -3.
-5//2 + 5//2 == -1, but (-5 + 5)//2 == 0.
So, don't be afraid to adopt the same approach as C, Javascript, and so on worrying that it's less correct or more error prone. Probably neither approach is really "better", it's just a matter of preference.
See http://en.wikipedia.org/wiki/Modulo_operation for a list of programming languages and how they chose to do integer division.
Apr 17, 2013, 3:56:10 AM
Posted to Why Python's Integer Division Floors