Lennart Augustsson <lennart <at> augustsson.net> writes:
> On Mon, Oct 27 2008, Bart Massey <bart <at> cs.pdx.edu> wrote:
> > I think given that the Haskell 98 Report is pretty
> > explicit about the behavior of round, we're stuck with
> > it, but I don't like it.  It's yet another tiny
> > impediment to Haskell newbies, as demonstrated by the
> > original post.
> 
> You're assuming newbies from a bad educational system that
> hasn't taught them how to round properly. :)

Naw. :-)

I'm just saying that the name "round" is unfortunate, since
there's no single universally accepted mathematical
definition for it. For this reason many programming
languages either don't provide it or provide a different
version.  The names "roundHalfUp" and "roundHalfEven" are
much better: they each correspond to a well-known
mathematical function that is codified in an IEEE standards
document.

If it were up to me, I'd deprecate round in Haskell' and
make the documentation point to these other rounding
functions.

Our solution in Nickle (http://nickle.org), BTW, was to
provide floating point with user-settable mantissa precision
and a default precision of 256 bits.  For all practical
purposes we know of, this makes worrying about the edge
cases for rounding pointless.  Kahan has a nice paper on
this that I can't find right now.

Of course, this solution also makes FP computation
creepingly slow, and exposes users to occasional bugs in our
FP math library... :-)

   Bart Massey
   bart <at> cs.pdx.edu


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to