Author: Robert Hyatt
Date: 17:04:16 09/10/02
Go up one level in this thread
On September 10, 2002 at 19:41:53, Dieter Buerssner wrote: >On September 09, 2002 at 23:10:20, Robert Hyatt wrote: > >>I can't believe _any_ compiler would use .001 since it can't be converted >>to IEEE FP exactly. Dividing by 1000 is far more preferable as 1000 _can_ >>be converted exactly. > >gcc -ffast-math > >Often (mostly?) this is nice. For example > > double a, b, c, d; > > /* I don't care about the last bit (only this can be different), but about > speed */ > a /= d; > b /= d; > /* Or should I write: > c = 1.0/d; > a *= c; > b *= c; > A clever compiler may know, which is faster for this specific architecture. > Many algorithms will work well either way, so one prefers the fastest method. > A strict IEEE-conforming floating point environment, of course must not > rearrange such expressions. > */ > >Regards, >Dieter That is a different issue IMHO. IE certainly you want to avoid divisions on the Cray since it could not divide. In fact, it had a "reciprocal approximation" instruction that computed 1/x to whatever accuracy you wanted. But if I give a compiler the /10 type operation, it should prefer that to *.1, because the /10 has enough error in it, the *.1 adds move because it is non-representable in a perfect conversion. I was commenting about the compiler arbitrarily replacing /1000.0 with *.001, which would seem to be bad math...
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.