[Haskell-cafe] Why 'round' does not just round numbers ?

Magnus Therning magnus at therning.org
Mon Oct 27 09:43:46 EDT 2008


On Mon, Oct 27, 2008 at 9:48 AM, L.Guo <leaveye.guo at gmail.com> wrote:
> Hi all:
>
>
> I just read about definitions of Prelude [1], and noticing that.
>
> In 6.4.6 Coercions and Component Extraction, it discribes like this:
>
>
> "round x returns the nearest integer to x, the even integer if x is equidistant between two integers."
>
>
> 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 ?
>
>
> [1] The Haskell 98 Report: Predefined Types and Classes
>    http://haskell.org/onlinereport/basic.html

This behaviour is not what I expect after reading the description at
http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:round
.  Given that this behaviour has caused a bit of confusion I think a
change to the documention might be in order.

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe


More information about the Haskell-Cafe mailing list