[Haskell-cafe] Re: Very fast loops. Now!
David Roundy
droundy at darcs.net
Mon Feb 12 17:28:00 EST 2007
On Mon, Feb 12, 2007 at 02:25:21PM -0800, Bryan O'Sullivan wrote:
> David Roundy wrote:
> >I'm rather curious (if you're sill interested) how this'll be affected by
> >the removal of the division from the inner loop. e.g.
> >
> > go :: Double -> Double -> Int -> IO ()
> > go !x !y !i
> > | i == 1000000000 = printf "%.6f\n" (x+y)
> > | otherwise = go (x*y*(1.0/3)) (x*9) (i+1)
> >
> >
> > for (; i<1000000000; i++) {
> > x = x*y*(1.0/3.0);
> > y = x*9.0;
> > }
>
> GCC will do the transformation itself if you use -ffast-math. It
> requires the flag as the results aren't exactly numerically equivalent.
Ah, okay. Never mind, then.
--
David Roundy
Department of Physics
Oregon State University
More information about the Haskell-Cafe
mailing list