title: Rounding error using the floor function in C++
body: <p>I was asked what will be the output of the following code:</p>
  
  <pre><code>floor((0.7+0.6)*10);
  </code></pre>
  
  <p>It returns 12. </p>
  
  <p>I know that the floating point representation does not allow to represent all numbers with infinite precision and that I should expect some discrepancies.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>How should I know that this piece of code returns 12, not 13? Why is (0.7+0.6)*10 a bit <strong>less</strong> than 13, not a bit <strong>more</strong>?</p></li>
  <li><p>When can I expect the floor function to work incorrectly and when it works correctly for sure?</p></li>
  </ol>
  
  <p>Note: I'm not asking how floating representation looks like or why the output isn't exactly 13. I'd like to know how should I infer that (0.7+0.6)*10 is a bit <strong>less</strong> than 13.</p>