Jonathan Cast ha scritto:
On Thu, 2009-02-05 at 01:10 +0100, Manlio Perillo wrote:
Yitzchak Gale ha scritto:
In our case, the Python division first does a quick estimate
of the sizes of the two integers, and just returns zero if it
sees that there will be underflow on conversion to double.
So I made the following rough change to the Haskell:
-- An exact division
(/.) :: Integer -> Integer -> Double
x /. y
| y `div` x > 5*10^323 = 0
| otherwise = fromRational $ toRational x / toRational y
Right, but I would like to see a proper implemented function for exact
integer division in GHC.
(%) *is* a proper function for exact integer division. But you'll find
plenty of Haskellers to balk at calling anything that returns a Double
`proper'.
After a quick search I found the function fromRat in GHC.Float, that
implement the division of two big integer returning a floating point number.
However it only supports rationals, and with rational there is a
performance problem caused by fraction reduction.
I would like to do some test with fraction reduction disabled, but right
now I don't have the time.
Regards Manlio Perillo
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe