[Haskell-cafe] Why 'round' does not just round numbers ?
voigt at tcs.inf.tu-dresden.de
Mon Oct 27 06:15:26 EDT 2008
Henning Thielemann wrote:
> 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 ...
Hmm, Henning, this is strange. The two of us went to the very same
school, but I know for a fact that I learnt 2.5 to round to 3, not 2 as
> 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
That is of course true (and was the topic of heated discussion with my
fourth grade math teacher), but does not explain 2.5 -> 2.
Dr. Janis Voigtlaender
mailto:voigt at tcs.inf.tu-dresden.de
More information about the Haskell-Cafe