[Haskell-cafe] Numeric Class Problem

Neil Mitchell ndmitchell at gmail.com
Sun Jan 28 13:04:29 EST 2007


Hi Dennis,

(/) :: Fractional a => a -> a -> a
div :: Integral a => a -> a -> a

Basically, use / on Float/Double like things, and div on Int/Integer
like things:

If you do want to use double like things throughout, then using
fromInteger around the place will help:

floor (fromInteger j * (fromInteger n / fromInteger p2n))

This converts easy value from an Integer to a number thing, which will
allow you to treat it like a Double/Float thing. If you are using Int
(rather than Integer) you might need fromInteger (toInteger x) around
the place.

Thanks

Neil


More information about the Haskell-Cafe mailing list