pan 87 Posted December 18, 2013 (edited) Hello, I was coding some modifications and I found out that sys_tick() is declared as int64 and I think it should've been declared as unsigned int64. In windows this function calls pGetTickCount64(), from winapi, which is declared as ULONGLONG that is equivalent to unsigned int64. @srccommontimer.c static int64 sys_tick(void) http://msdn.microsoft.com/en-us/library/windows/desktop/ms724411(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/cc230393.aspx Edited December 18, 2013 by pan Quote Share this post Link to post Share on other sites
Haru 290 Posted December 18, 2013 There were reasons why signed was chosen instead of unsigned. Most operations we do with tick are tick differences, and that kind of operation with unsigned variables requires extra care that's not required with signed ones. There really isn't any benefit in using unsigned in most cases (especially if it's just to say that the variable should never be negative), and I strongly believe the only place where one should use unsigned is where the value isn't used as a plain number, but a bit field or similar. If the point about using unsigned is to allow larger values, well, the int64 overflow will happen about 292 million years from now. I believe that, whichever intelligent life forms will be alive by then, if any, will be able to use a different 'zero', or a larger variable. This article on the topic is an interesting read: http://www.soundsoftware.ac.uk/c-pitfall-unsigned 2 AnnieRuru and pan reacted to this Quote Share this post Link to post Share on other sites
pan 87 Posted December 18, 2013 Thank you for recommending the article, it's very good indeed. Sorry for any inconvenience :x Quote Share this post Link to post Share on other sites