From: Robert Klemme Date: 2011-09-12T18:39:46+09:00 Subject: Re: How do I make output generate a float without an excess numbers of decimal places? 2011/9/11 Bartosz DziewoƄski : > 2011/9/11 Joe Collins : >> I tried n.round(2) and gave an error - didnt want the 2 argument. I am >> using an older version of ruby? >> > > In 1.8.x, round() simply rounded to nearest integer. > > http://www.ruby-doc.org/core-1.8.7/classes/Float.html#M000650 > > You should update to Ruby 1.9.2. Also, rounding is rarely what one wants because it looses precision and still gives no guarantee for proper output formatting. Usually output formatting with printf, sprintf or % operator is better. Btw, Joe if you are using floating point numbers for currency values you might run into trouble soon because of the pecularities of IEEE floating point math. In those cases it might be better to use BigDecimal. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/