compare on Double

Neil Mitchell ndmitchell at
Thu Mar 22 10:50:42 EDT 2007


> Note that in the bytestring case the compiler doesn't do so, it's the
> library that does (by telling the compiler to rewrite things with
> RULEs).

ByteString is in base, and ships with GHC, I think that makes it GHC's
fault if it does naughty things.

> Unfortunately, it's very appealing in bytestring's case...

Yes, the dilema between performance and purity...

> > For reference, my Catch tool treats Float/Double compare as never
> > crashing, and division by zero as always crashing
> Even for Double/Float?


> There's also:
>     Prelude> (minBound :: Int) `div` (-1)
>     *** Exception: arithmetic overflow
> but you probably can't do much about that in Catch.

There is an easy solution, always use Integers. Catch also assumes
rules like adding two positive numbers results in a positive number -
which unfortunately isn't actually true.



More information about the Libraries mailing list