Hi,
I ran the code beloew but with different version of the "if" statement. Do either boolean, int or double comparisons. Astonishingly, they all give the same order of timings! I would have assumed that boolean would be MUCH fatser than doubles.
Can anyone explain why this is?
Moon
std::clock_t start;
std::clock_t end;
double diff;
int i;
int a = 2;
int b= 3;
bool ba = true;
bool bb = false;
double da = 2.0;
double db = 3.0;
double cc;
string input = "";
printf("Start\n");
start = std::clock();
for (i=0;i<4000000000;i++)
{
if (da==db) //CHANEGS MADE HERE
{
cc = 2.0+i;
da == cc;
}
else
{
cc = 2.0+i;
db = cc;
}
}
end = std::clock();
diff = ( end - start) / (double) CLOCKS_PER_SEC;
printf ("Done[%f]: %f\n",cc,diff);
//getline(cin,input);
return 0;