
6 May
2007
6 May
'07
12:21 p.m.
On Sun, May 06, 2007 at 05:15:08PM +0100, Andrew Coppin wrote:
Greetings.
Haskell has arbitrary precision integers, in the form of the Integer type. Is there a type somewhere that implements arbitrary precision fractional values?
Yes, Rational in the Prelude (with extra functions in Ratio) Prelude> let fibs = (1::Rational) : 1 : zipWith (+) fibs (tail fibs) Prelude> let grs = zipWith (/) (tail fibs) fibs Prelude> take 10 grs [1%1,2%1,3%2,5%3,8%5,13%8,21%13,34%21,55%34,89%55] Prelude> take 10 (zipWith (-) grs (tail grs)) [(-1)%1,1%2,(-1)%6,1%15,(-1)%40,1%104,(-1)%273,1%714,(-1)%1870,1%4895] Prelude>