This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Mar 14, 2004, at 15:39, Scott Robert Ladd wrote:
Hello,
Consider the following program, compiled and run on a Pentium 4 (Northwood) system:
#include <math.h> #include <stdio.h>
double doit(double a) { double s = sin(a); double c = cos(a);
// should always be 1 return s * s + c * c; }
int main(void) { double a = 1.0, r = 0.0;
for (int i = 0; i < 100000000; ++i) r += doit(a);
printf("r = %f\n",r); return 0; }
The point here if you know that it is 1.0 then just return 1.0 instead of trying to play tricks with trig functions.
-- Scott Robert Ladd Coyote Gulch Productions (http://www.coyotegulch.com) Software Invention for High-Performance Computing
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |