compare on Double

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


Hi

> 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?

Yes.

> 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.

Thanks

Neil


More information about the Libraries mailing list