wish: optimize (x > 0.) floating point comparison.
Robert L Krawitz
rlk@tiac.net
Tue Sep 22 16:05:00 GMT 1998
Date: Tue, 22 Sep 1998 13:31:41 -0700
From: Yotam Medini <yotam@avanticorp.com>
Good point.
I am not familier with the (IEEE?) standard of floating-point representation.
May be a the following pseudo code (with lazy || evaluation)
bool positive(double x)
{ return((highBit(x) == 0) || ((bitwise)x == (bitwise)(-0.0))); }
is still faster?
BTW, there's another issue, which cuts both ways: FP numbers in the
FPU have more precision and range (64/15) than FP numbers in memory
(52/11). Storing intermediate results in memory causes zero to be
stored if the exponent is very negative. So if you have -1E-2000, for
example, storing it out to memory will store a zero (probably -0.0,
but zero nonetheless).
I've personally had more problems with the excess precision than
benefits (in fact, usually involving comparisons with zero!), but that
depends upon exactly what you're doing.
--
Robert Krawitz <rlk@tiac.net> http://www.tiac.net/users/rlk/
Tall Clubs International -- http://www.tall.org/ or 1-888-IM-TALL-2
Member of the League for Programming Freedom -- mail lpf@uunet.uu.net
"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton
More information about the Gcc
mailing list