Topic: Float Truncating Question

I can't find any Ruby methods that will truncate a float to, say, the hundredth position and round up if necessary.  Does anything exist or do I need to write this one myself?

Edit: I can write this easily, I just wanted to keep things clean and use a built in method if one exists.

Last edited by BIGtrouble77 (2007-06-17 21:15:42)

Re: Float Truncating Question

irb(main):014:0> sprintf("%.3f", 1.987654321)
=> "1.988"

Re: Float Truncating Question

Thanks, that's much shorter than what I have.