title: Rounding (math.h) in C not working as it should
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  int main(){
    printf("Rounded value of 6*0.95*0.25 = %.2f\n", round(6*0.95*0.25*100)/100);
    printf("Rounded value of 1.425 = %.2f\n", round(1.425*100)/100);
  }
  </code></pre>
  
  <p>I have a suspicion that it is to do with the accuracy of the doubles and respective arithmetic, but how I can solve this (such that 6*0.95*0.25 which is 1.425 will round to 1.43) I have no idea....</p>
  
  <p>(I am using the GNU compiler latest version (1.7 something))</p>
  
  <p>help appreciated</p>
  
  <p>I am trying to round to 2 d.p.</p>
  
  <p>The following is the output:</p>
  
  <p>Rounded value of 6*0.95*0.25 = 1.42<br>
  Rounded value of 1.425 = 1.43 </p>
  
  <p>( <a href="https://onlinegdb.com/r1ZtZ2lCW" rel="nofollow noreferrer">https://onlinegdb.com/r1ZtZ2lCW</a> )</p>
  
  <p>I want</p>
  
  <p>Rounded value of 6*0.95*0.25 = 1.43<br>
  Rounded value of 1.425 = 1.43 </p>