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

http://code.python.org/hg/trunk/file/tip/Objects/longobject.c#l2657

> [...]


Thanks  Manlio Perillo
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to