title: string format with %g in C
body: <p>How do I create a string so that it formats floating point numbers to have no trailing decimal point or digits when it is an integer, but to NOT switch to scientific notation for larger numbers?</p>
  
  <p>When I do:</p>
  
  <pre><code>float myFloat= 15.6f;
  float myInt = 5.0f;
  float myLarge = 7000000.0f;
  sprintf(out, "my float is %g", myFloat);
  sprintf(out, "my int is %g", myInt);
  sprintf(out, "my large is %g", myLarge);
  </code></pre>
  
  <p>I get something like:</p>
  
  <pre>
  my float is 15.6
  my int is 5
  my large is 7e+07f
  </pre>
  
  <p>I want all a single format string that will give 15.6, 5, and 700000.</p>
  
  <p><em>Edited cause comments don't do formatting:</em></p>
  
  <p>that's what I thought. but a wrapper is pretty inconvenient though as the format strings are embedded in longer format strings: </p>
  
  <pre><code>sprintf(buf, "%d %g", myInt, myFloat);
  </code></pre>
  
  <p>how do you wrap that? </p>
  
  <pre><code>sprintf(buf, "%d %g", myInt, Wrapper(myFloat));??
  </code></pre>
  
  <p>what should Wrapper return? Or worse:</p>
  
  <pre><code>sprintf(buf, "%d %s", myInt, Wrapper(myFloat));?? 
  </code></pre>