I'm not one of the implementors, but this sort of behavior can reduce error in fields where X.5 is a common result- a rule like "The nearest even integer" moves upward half the time and downward half the time- hopefully cancelling itself out. Or maybe they had other reasons... Joe
-----Original Message----- From: Rijk-Jan van Haaften [mailto:rjchaaft@cs.uu.nl] Sent: Wednesday, May 09, 2001 8:06 AM To: haskell@haskell.org Subject: Class RealFrac: round
Hello,
While I were writing a RealFrac implementation for BigDouble's (for high-precision computations) I found a strange implementation of round in the standard prelude (from the haskell definition):
...
The strange case is if signum (abs r - 0.5) is 0: such numbers are round to the nearest EVEN integer. In mathematics, computer science (the studies I'm doing) and physics, as far as I know, it is usual to round such numbers up, rather than to the nearest integer. For example:
Number Hugs Math 0.5 0 1 1.5 2 2 -3.5 -4 -4 6.5 6 7
Why did the Haskell designers choose this behaviour?
Thanks in advance,
Rijk-Jan van Haaften
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
participants (1)
-
Joe Bowers