Martin Coxall
10/13/2006 3:32:00 PM
On 10/13/06, Martin Coxall <pseudo.meta@gmail.com> 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