title: Ruby float without any zero after decimal point
body: <p>I had searched a lot to get my exact requirement for getting the <code>float</code> value without unwanted zero after decimal.</p>
  
  <pre><code>Eg:  14.0 should be 14
       14.1 should be 14.1
  </code></pre>
  
  <p>Nearest possible solution I found so far is using <a href="http://goo.gl/00cYAo" rel="noreferrer"><code>sprintf()</code></a>:</p>
  
  <pre><code>irb(main):050:0&gt; num = 123.0
  =&gt; 123.0
  irb(main):051:0&gt; sprintf('%g', num)
  =&gt; "123"
  </code></pre>
  
  <p>Problem here is my <code>num</code> type changed to <code>String</code> from <code>Float</code>. 
  Can I get the float value change without its type changed?</p>