From: "Cameron, Gemma (UK)" Date: 2006-10-16T16:50:25+09:00 Subject: Re: How do I round off a float to x decimal places Might be a little late but here's my method # round only works on integers so have to # multiply the float to by 10000 to round it to 2 decimal places # and then correct the position of the decimal by # dividing by 100.0 def round(float, num_of_decimal_places) exponent = num_of_decimal_places + 2 @float = float*(10**exponent) @float = @float.round @float = @float / (10.0**exponent) end Gem -----Original Message----- From: Jatinder Singh [mailto:jatinder.saundh@gmail.com] Sent: 13 October 2006 17:13 To: ruby-talk ML Subject: Re: How do I round off a float to x decimal places *** WARNING *** This mail has originated outside your organization, either from an external partner or the Global Internet. Keep this in mind if you answer this message. ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************