[Haskell-cafe] Why 'round' does not just round numbers ?
lemming at henning-thielemann.de
Mon Oct 27 06:00:05 EDT 2008
On Mon, 27 Oct 2008, L.Guo wrote:
> I think this is unresonable. then try it in GHC 6.8.3.
> Prelude> round 3.5
> Prelude> round 2.5
> Is there any explanation about that ?
It's the definition we learnt in school ...
I think one reason is that repeated rounding should not be worse than
rounding in one go. Consider the rule 'use ceiling when the first removed
digit is 5'. Then
0.45 - (round to one place) -> 0.5 - (round to integer) -> 1
0.45 - (round to integer) -> 0
This is avoided by the school definition.
More information about the Haskell-Cafe