
6 May
2007
6 May
'07
12:59 p.m.
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>
Ah yes, you're right. Well, you learn something every day... OOC, is there a reason why you can't just write "5%10"?