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

Lennart Augustsson lennart at augustsson.net
Tue Oct 28 13:36:07 EDT 2008


I agree that the name is not the most descriptive one, and perhaps we
should have the more descriptive ones.
But when I hear "round", I assume it's the kind of rounding Haskell
does.  And I assumed this before Haskell came about.

On Tue, Oct 28, 2008 at 6:07 PM, Bart Massey <bart at cs.pdx.edu> wrote:
> 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list