[Haskell-cafe] Why 'round' does not just round numbers ?
neil.mitchell.2 at credit-suisse.com
Mon Oct 27 06:01:38 EDT 2008
That is a fairly standard implementation of rounding for financial
sum . map round
Over the list [3.5,2.5]
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
For more details see:
> -----Original Message-----
> From: haskell-cafe-bounces at haskell.org
> [mailto:haskell-cafe-bounces at haskell.org] On Behalf Of L.Guo
> Sent: 27 October 2008 9:49 am
> To: MailList Haskell-Cafe
> Subject: [Haskell-cafe] Why 'round' does not just round numbers ?
> Hi all:
> I just read about definitions of Prelude , 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
> Prelude> round 2.5
> Is there any explanation about that ?
>  The Haskell 98 Report: Predefined Types and Classes
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Please access the attached hyperlink for an important electronic communications disclaimer:
More information about the Haskell-Cafe