title: Formatting floats without trailing zeros
body: <p>How can I format a float so that it doesn't contain trailing zeros? In other words, I want the resulting string to be as short as possible.</p>
  
  <p>For example:</p>
  
  <pre><code>3 -&gt; "3"
  3. -&gt; "3"
  3.0 -&gt; "3"
  3.1 -&gt; "3.1"
  3.14 -&gt; "3.14"
  3.140 -&gt; "3.14"
  </code></pre>