title: Only show decimal point if floating point component is not .00 sprintf/printf
body: <p>I am pretty formatting a floating point number but want it to appear as an integer if there is no relevant floating point number.</p>
  
  <p>I.e.</p>
  
  <ul>
  <li>1.20 -> 1.2x</li>
  <li>1.78 -> 1.78x</li>
  <li>0.80 -> 0.8x</li>
  <li>2.00 -> 2x</li>
  </ul>
  
  <p>I can achieve this with a bit of regex but wondering if there is a <code>sprintf</code>-only way of doing this?</p>
  
  <p>I am doing it rather lazily in ruby like so:</p>
  
  <pre><code>("%0.2fx" % (factor / 100.0)).gsub(/\.?0+x$/,'x')
  </code></pre>