[Haskell-cafe] about integer and float operations

Jonathan Cast jonathanccast at fastmail.fm
Wed Feb 4 19:22:07 EST 2009


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

jcc




More information about the Haskell-Cafe mailing list