title: How do I round a float to a specified number of significant digits in Ruby?
body: <p>It would be nice to have an equivalent of <a href="http://rss.acs.unt.edu/Rdoc/library/base/html/Round.html" rel="noreferrer">R's signif</a> function in Ruby.</p>
  
  <p>For example:</p>
  
  <pre><code>&gt;&gt; (11.11).signif(1)
  10
  &gt;&gt; (22.22).signif(2)
  22
  &gt;&gt; (3.333).signif(2)
  3.3
  &gt;&gt; (4.4).signif(3)
  4.4 # It's usually 4.40 but that's OK. R does not print the trailing 0's
      # because it returns the float data type. For Ruby we want the same.
  &gt;&gt; (5.55).signif(2)
  5.6
  </code></pre>