title: What is the reason for difference between integer division and float to int conversion in python?
body: <p>I have recently noticed that <a href="https://docs.python.org/3/library/functions.html#int" rel="nofollow noreferrer"><code>int()</code></a> rounds a float towards 0, while <a href="https://docs.python.org/3/glossary.html#term-floor-division" rel="nofollow noreferrer">integer division</a> rounds a float towards its floor.</p>
  <p>for instance:</p>
  <pre><code>-7 // 2 == -4
  int(-7/2) == -3
  </code></pre>
  <p>I have read the documentation which specifies:</p>
  <blockquote>
  <p>class int(x, base=10)</p>
  <p>Return an integer object constructed from a number or string x, or return 0 if no arguments are &gt;given. If x is a number, return <code>x.__int__()</code>. For floating point numbers, <strong>this truncates towards zero.</strong></p>
  </blockquote>
  <p>and:</p>
  <blockquote>
  <p>floor division</p>
  <p>Mathematical division that rounds <strong>down to nearest integer.</strong> The floor division operator is <code>//</code>. For example, the expression <code>11 // 4</code> evaluates to 2 in contrast to the <code>2.75</code> returned by float true division. Note that <code>(-11) // 4</code> is <code>-3</code> because that is <code>-2.75</code> rounded downward. See <a href="https://www.python.org/dev/peps/pep-0238" rel="nofollow noreferrer">PEP 238</a>.</p>
  </blockquote>
  <p>But it seems illogical for me that 2 similar operations (float division to integer) should return different results.</p>
  <p>Is there any motivation for the differences between the functions?</p>