title: Determining output (printing) of float with %f in C/C++
body: <p><code>I have gone through earlier discussions on floating point numbers in SO but that didn't clarified my problem,I knew this floating point issues may be common in every forum but my question in not concerned about Floating point arithmetic or Comparison.I am rather inquisitive about its representation and output with %f.</code>  </p>
  
  <p>The question is straight forward :<strong>"How to determine the exact output of :</strong></p>
  
  <pre><code>float = &lt;Some_Value&gt;f;     
  printf("%f \n",&lt;Float_Variable&gt;);
  </code></pre>
  
  <p>Lets us consider this code snippet:</p>
  
  <pre><code>float f = 43.2f,
  f1 = 23.7f,
  f2 = 58.89f,
  f3 = 0.7f;
  
  printf("f1 = %f\n",f);
  printf("f2 = %f\n",f1);
  printf("f3 = %f\n",f2);
  printf("f4 = %f\n",f3);
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>f1 = 43.200001
  f2 = 23.700001
  f3 = 58.889999
  f4 = 0.700000
  </code></pre>
  
  <p>I am aware that %f (is meant to be for double) has a default precision of 6, also I am aware that the problem (in this case) can be fixed by using double but I am inquisitive about the output <code>f2 = 23.700001</code> and <code>f3 = 58.889999</code> in float.</p>
  
  <p><code>EDIT: I am aware that floating point number cannot be represented precisely, but what is the rule of for obtaining the closest representable value ?</code> </p>
  
  <p>Thanks,</p>