title: scanf in C (for scanning a float) and the issue with precision
body: <p>I searched but couldn't find anyone with my problem.<br>
  I have this :</p>
  
  <pre><code>    float num;
      scanf("%f" , &amp;num);
  </code></pre>
  
  <p>But actually when I enter 4.2 it assumes it is 4.199999999.
  Why?<br>
  what should I do with this issue? I want to use 4.2, but all my calculations ruined.</p>
  
  <p>edit:
  Wow @chux 's answer was wonderful. I didn't know that function exists. this:</p>
  
  <pre><code>num = roundf(n * 100);
  </code></pre>
  
  <p>is the trick I needed.</p>