[Haskell-cafe] about integer and float operations

Manlio Perillo manlio_perillo at libero.it
Wed Feb 4 17:26:25 EST 2009


Max Rabkin ha scritto:
> [...]
> 
>> Here is an Haskell version:
>> http://paste.pocoo.org/show/102801/
>>
>> On my system it takes 30 seconds.
> 
> You're only dividing integers by integers to get Doubles.
> 
> x /. y = fromIntegral x / fromIntegral y
> 
> works just fine in this case.
> 

No, this *does not works*.

I get Nan as result, since fromIntegral a, when a is out of range of a 
double, returns Infinity.

Prelude> (fromIntegral (fac 777)) :: Double
Infinity


CPython, does not try to convert to double, but, instead, to a scaled 
double.


> --Max
> 


Manlio Perillo


More information about the Haskell-Cafe mailing list