10.3 % 2.5 prints 0.3 or 0.3000000000000007
<p>Can someone please explain in detail why in Python 2.7</p>

<pre><code>10.3 % 2.5 =&gt; 0.3
</code></pre>

<p>and in Python 3.0 prints <code>0.3000000000000007</code> (probably due to representation issues)</p>

<p>And, moreover, <code>10.3 % 2.5 - 0.3</code> prints <code>7.216449660063518e-16</code> in both Pythons.</p>

<p>The error I can imagine that is due to float representation, but why the change in print behavior and what can be done to avoid it when converting programs from 2 to 3?</p>