From: Martin Coxall Date: 2006-10-14T00:32:26+09:00 Subject: Re: How do I round off a float to x decimal places On 10/13/06, Martin Coxall wrote: > > Hi, > > > > This might be a very naive question but I looked through ruby:Float > > documentation for a method which round off's a float number to x decimal > > places with no luck. > > > > Please share if you know. > > It rather depends on which of the 14-or-so regulalrly used rounding > algorithms you need. > > Float#round has an inbuilt bias toward zero and is therefore not a > useful unbiased rounding in many circumstances. > But, to answer your original question: if you want a number to three decimal places: Multiply by 10^n Round() Divide by 10^n Martin