title: Round-off / round-up criteria in Python
body: <p>I'm porting a MATLAB code to Python 3.5.1 and I found a float round-off issue.</p>
  
  <p>In MATLAB, the following number is rounded <strong>up</strong> to the 6th decimal place:</p>
  
  <pre><code>fprintf(1,'%f', -67.6640625);
  -67.664063
  </code></pre>
  
  <p>In Python, on the other hand, the following number is rounded <strong>off</strong> to the 6th decimal place:</p>
  
  <pre><code>print('%f' % -67.6640625)
  -67.664062
  </code></pre>
  
  <p>Interestingly enough, if the number is '-67.6000625', then it is rounded <strong>up</strong> even in Python:</p>
  
  <pre><code>print('%f' % -67.6000625)
  -67.600063
  </code></pre>
  
  <p>... Why does this happen?
  What are the criteria to round-off/up in Python?
  (I believe this has something to do with handling hexadecimal values.)</p>
  
  <p>More importantly, how can I prevent this difference?
  I'm supposed to create a python code which can reproduce exactly the same output as MATLAB produces.</p>