[Haskell-cafe] Why 'round' does not just round numbers ?
Henning Thielemann
lemming at henning-thielemann.de
Mon Oct 27 06:20:40 EDT 2008
On Mon, 27 Oct 2008, Janis Voigtlaender wrote:
> 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
>>> 4
>>> Prelude> round 2.5
>>> 2
>>>
>>>
>>> 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
> above. ;-)
I meant the school before GCG! :-]
So it seems to differ between schools and even teachers. (Much like the
question whether zero should be counted as natural number or not.)
>> 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
>>
>> but
>>
>> 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.
Because doing otherwise would be odd rounding. ;-)
More information about the Haskell-Cafe
mailing list