title: What's the mathematical reason behind Python choosing to round integer division toward negative infinity?
body: <p>I know Python <code>//</code> rounds towards negative infinity and in C++ <code>/</code> is truncating, rounding towards 0.</p>
  <p>And here's what I know so far:</p>
  <pre class="lang-none prettyprint-override"><code>               |remainder|
  -12 / 10  = -1,   - 2      // C++
  -12 // 10 = -2,   + 8      # Python
  
  12 / -10  = -1,     2      // C++
  12 // -10 = -2,   - 8      # Python
  
  12 / 10  = 1,      2       // Both
  12 // 10 = 1,      2
  
  -12 / -10 = 1,    - 2      // Both
            = 2,    + 8
  
  C++:
  1. m%(-n) == m%n
  2. -m%n == -(m%n)
  3. (m/n)*n + m%n == m
  
  Python:
  1. m%(-n) == -8 == -(-m%n)
  2. (m//n)*n + m%n == m
  </code></pre>
  <p>But why Python <code>//</code> choose to round towards negative infinity? I didn't find any resources explain that, but only find and hear people say vaguely: <em>&quot;for mathematics reasons&quot;</em>.</p>
  <p>For example, in <em><a href="https://stackoverflow.com/questions/22030342/why-is-1-2-evaluated-to-0-in-c-but-1-in-python">Why is -1/2 evaluated to 0 in C++, but -1 in Python?</a></em>:</p>
  <blockquote>
  <p>People dealing with these things in the abstract tend to feel that
  rounding toward negative infinity makes more sense (<strong>that means it's
  compatible with the modulo function as defined in mathematics, rather
  than % having a somewhat funny meaning</strong>).</p>
  </blockquote>
  <p>But I don't see C++ 's <code>/</code> not being compatible with the modulo function. In C++, <code>(m/n)*n + m%n == m</code> also applies.</p>
  <p>So what's the (mathematical) reason behind Python choosing rounding towards negative infinity?</p>
  <hr />
  <p>See also <a href="http://python-history.blogspot.com/2010/08/why-pythons-integer-division-floors.html" rel="noreferrer">Guido van Rossum's old blog post on the topic</a>.</p>