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

Felipe Lessa felipe.lessa at gmail.com
Tue Oct 28 06:40:54 EDT 2008

On Mon, Oct 27, 2008 at 6:15 PM, Bart Massey <bart at cs.pdx.edu> wrote:
> BTW, in case anyone is unclear, IEEE 854 supports a large
> variety of required and optional rounding modes; it takes no
> strong position on a "correct" rounding strategy. In
> particular, round-up ("round-half-up") and round-to-even
> ("round-half-even") are both required. However, there is an
> IEEE 854 subset, ANSI X3.274, that does make rounding modes
> other than round-up optional, presumably in conformance with
> common PL practice. This might make an implementation of the
> Report's round function on some FPU I've never heard of
> slightly more expensive.

I would like to see something on the lines of

data RoundMode = RoundUp | RoundDown | RoundToZero | RoundHalfEven

class (Real a, Fractional a) => RealFrac a where
  round :: (Integral b) => a -> b
  roundBy :: (Integral b) => RoundMode -> a -> b
  roundModes :: a -> [RoundMode] -- non-strict on argument


More information about the Haskell-Cafe mailing list