[Haskell-cafe] Floating phi, round and even Fibonnaci numbers

haskell at list.mightyreason.com haskell at list.mightyreason.com
Tue Jul 10 17:31:46 EDT 2007


But that also depended on phi defaulting to Double in even_fibs.

To be clearer:

> even_fibs :: (Integral t) => [t]
> even_fibs = iterate (\x -> round(fromIntegral x * (dp**3))) 2
>   where dp :: Double
>         dp = phi

The above is equivalent to the previous.

The below uses less precision:

> 
> even_fibs' :: (Integral t) => [t]
> even_fibs' = iterate (\x -> round(fromIntegral x * (dp**3))) 2
>   where dp :: Float
>         dp = phi


So it fails earlier:

> head $ dropWhile (uncurry (==)) $ zip even_fibs' even_fibs_2
> (14930353,14930352)



More information about the Haskell-Cafe mailing list