title: is (0.1 + 0.2) == 0.3 true or false?
body: <p>I have a basic understanding in float-point number and was reading <a href="https://www.evanjones.ca/floating-point-money.html" rel="nofollow noreferrer">this article</a> which says:</p>
  <blockquote>
  <p>0.1 + 0.2: This equals 0.3, but in floating-point: <code>(0.1 + 0.2) == 0.3</code> is false. This is because 0.1, 0.2 and 0.3 cannot be precisely represented in base 2 floating-point.</p>
  </blockquote>
  <p>Well, that's true according to the nature of floating point number, but I wrote a simple program to test:</p>
  <pre class="lang-c prettyprint-override"><code>float a = 0.1;
  float b = 0.2;
  
  if(a+b == 0.3)
  {
    printf(&quot;true&quot;);
  } else 
  {
    printf(&quot;false&quot;);
  }
  // result is true
  </code></pre>
  <p>but the output is actually <code>true</code>. Here is my two questions:</p>
  <ol>
  <li><p>I think what happens is, because C uses the round-to-even rounding mode, so after rounding, it happens to be true, is my understanding correct?</p>
  </li>
  <li><p>If my understanding is correct, then there must be some specified float-point number won't be true in this case, because there is still a small chance that rounding might fail. So that must be some combination as</p>
  <pre class="lang-c prettyprint-override"><code>float a = ...;
  float b = ...;
  if(a+b == XXX)  // where XXX is the &quot;intuitive&quot; sum of a and b
  {
    printf(&quot;true&quot;);
  } else 
  {
    printf(&quot;false&quot;);   
  }
  
  //result is false now
  </code></pre>
  </li>
  </ol>
  <p>Is my understanding correct?</p>