[Haskell-cafe] about integer and float operations

Manlio Perillo manlio_perillo at libero.it
Wed Feb 4 16:38:50 EST 2009


Ross Mellgren ha scritto:
> Prelude> let i2fDiv a b = fromIntegral a / fromIntegral b
> Prelude> :t i2fDiv
> i2fDiv :: (Integral a, Fractional b, Integral a1) =>
>                  a -> a1 -> b
> Prelude> 10 `i2fDiv` 3
> 3.3333333333333335
> 

Prelude> fac 777 `i2fDiv` fac 777
NaN

> That what you're looking for?
> 

No.
I'm looking for an exact integer division that avoids overflows, if 
possible.

> -Ross
> 


Manlio Perillo


More information about the Haskell-Cafe mailing list