Why round(4.5) == 4 and round(5.5) == 6 in Python 3.5?
<p>Looks like both 4.5 and 5.5 have exact float representations in Python 3.5:</p>

<pre><code>&gt;&gt;&gt; from decimal import Decimal
&gt;&gt;&gt; Decimal(4.5)
Decimal('4.5')
&gt;&gt;&gt; Decimal(5.5)
Decimal('5.5')
</code></pre>

<p>If this is the case, then why</p>

<pre><code>&gt;&gt;&gt; round(4.5)
4
&gt;&gt;&gt; round(5.5)
6
</code></pre>

<p>?</p>

<p>In Python 3, exact half way numbers are rounded to the nearest even result. This <a href="https://docs.python.org/3/whatsnew/3.0.html#builtins">behavior changed in Python 3</a></p>

<blockquote>
  <p>The <a href="https://docs.python.org/3/library/functions.html#round"><code>round()</code></a> function rounding strategy and return type have changed. Exact halfway cases are now rounded to the nearest even result instead of away from zero. (For example, round(2.5) now returns 2 rather than 3.) round(x[, n]) now delegates to x.<strong>round</strong>([n]) instead of always returning a float. It generally returns an integer when called with a single argument and a value of the same type as x when called with two arguments.</p>
</blockquote>

python floating-point floating-accuracy