|
|
Warp wrote in message <44f1fe00@news.povray.org>:
> Nicolas George <nicolas$george@salle-s.org> wrote:
>> for(i = 0; i <= N; i++)
>> r += (double)i * (i / 100000000);
>
> What is the type of 'i' there?
An unsigned; but it should not change anything, since it is the very same
code in both modes. Well, it could have been a long long, but I am not that
careless; and in fact, the difference between 64-bit integer arithmetic in
both modes is much smaller. Some of the missing parts are:
#define N 1000000000
static double
calc_double(void)
{
unsigned i;
register double r = 0; /* or not register */
for(i = 0; i <= N; i++)
r += (double)i * (i / 100000000);
return(r);
}
getrusage(RUSAGE_SELF, &t0);
r1 = calc_double();
getrusage(RUSAGE_SELF, &t1);
(the rest is just necessary noise)
Post a reply to this message
|
|