[Haskell-cafe] Why 'round' does not just round numbers ?
ajb at spamcop.net
ajb at spamcop.net
Mon Oct 27 21:08:04 EDT 2008
G'day all.
Quoting "Mitchell, Neil" <neil.mitchell.2 at credit-suisse.com>:
> With rounding to the nearest even integer for 0.5's you get 6, otherwise
> if you always round up you get 7. If you bias towards rounding up you
> get a general upwards trend as numbers are rounded, which is bad, while
> the even condition ensures that statistically it averages to the same
> thing.
There are also many numeric algorithms for which the rounding pattern
in the least-significant digit is somewhat systematic. A simple example
might be this:
x <- round(x + 0.5)
x <- round(x - 0.5)
x <- round(x + 0.5)
x <- round(x - 0.5)
... etc
If you try this procedure starting with, say, x = 1.5, you can see a
clear difference between round-up and round-to-even. With round-up,
the rounding error is keeps increasing as the procedure continues. With
round-to-even, the error is bounded.
Cheers,
Andrew Bromage
More information about the Haskell-Cafe
mailing list