From: Dan Nachbar Date: 2011-09-11T19:08:06+09:00 Subject: Re: How do I make output generate a float without an excess numbers of decimal places? On Sep 11, 2011, at 5:47 AM, Kane Williams wrote: > Dan Nachbar wrote in post #1021235: >> You might try using the % instance method of String. >> For example: >> "%.2f" % (1.0/3) => "0.33" >> >> Dan Nachbar > > Would you mind explaining the >> "%.2f" > part? What does the % do? And what does the f do? Thanks! There are quite a few online resources that cover the details much better than I can. A quick google search turns up several. For example, see http://4loc.wordpress.com/2008/09/24/formatting-dates-and-floats-in-ruby/ The formats are the same as the ones used by sprintf and can be found in the documentation for that method - http://ruby-doc.org/core/classes/Kernel.html#M001432 Most books on ruby also cover this topic to some degree. Dan Nachbar