Quote:
Originally Posted by dav
one other thing - is current_clock, etc. ever negative? it doesn't seem so, therefore why not make those values unsigned longs instead of just longs, and thus get 2^32-1 clock ticks till rollover instead of 2^31-1?
second thing, the return value should probably be a double if you are passing back time_in_seconds, which is a double.
|
As PMB says, clock() returns a signed long. The only reason for it that I can see, is that it will return -1 if the clock() result is unavailable for whatever reason. Seems silly when they could of had it start from 1 to 2^32-1 and used 0 as the invalid result, or used another method.
In any case, I think the function we now have (once
float is replaced with
double and all optimizations are put in place) is about as good as it can get.
*edit*
I guess we should have the function check for the -1 result if clock() ever returned it