View Single Post
Re: need your advice on clock()
Old
  (#13)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: need your advice on clock() - 15-01-2004

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


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut

Last edited by botmeister; 15-01-2004 at 06:29..
  
Reply With Quote