[Haskell-cafe] about integer and float operations

Manlio Perillo manlio_perillo at libero.it
Wed Feb 4 17:13:41 EST 2009

Yitzchak Gale ha scritto:
> [...]
> exactDiv :: (Real a, Real b, Fractional c) => a -> b -> c
> x `exactDiv` y = realToFrac x / realToFrac y
> Python does that same type coercion automatically at runtime.

No, this is not correct.

CPython converts to float only for a "simple" integer (since conversion 
from machine int to machine float will never overflow).

For a "long integer" it uses a special algorithm for computing the 
division, that avoids overflow if the final result is in the range of a 


 > [...]

Thanks  Manlio Perillo

More information about the Haskell-Cafe mailing list