View Issue Details

IDProjectCategoryView StatusLast Update
0001997Spring engineGeneralpublic2010-07-23 23:02
ReporterSirMaverick Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Product Version0.81.2+git 
Summary0001997: os.clock not continuous
Descriptionos.clock() = 2147.3200683594, next second: -2147.4272460938

Overflow?
Additional Informationwidget output:
os.clock error, 2147.3200683594, -2147.4272460938
TagsNo tags attached.
Attached Files
test_ostime.lua (Attachment missing)
Checked infolog.txt for Errors

Activities

Kloot

2010-07-23 23:01

developer   ~0005147

Last edited: 2010-07-23 23:01

static int os_clock(lua_State *L) {
  lua_pushnumber(L, ((lua_Number)clock()) / (lua_Number)CLOCKS_PER_SEC);
  return 1;
}

1) lua_Number is a float
2) clock() "returns the number of clock ticks elapsed since the program was launched" (in a variable of type clock_t, which on most systems is just an int32 or long32)
3) CLOCKS_PER_SEC is a constant, usually 1000000

Therefore the fact that it overflows after 2147 seconds (2.147 billion ticks) is expected behavior.

Issue History

Date Modified Username Field Change
2010-07-23 21:33 SirMaverick New Issue
2010-07-23 21:33 SirMaverick File Added: test_ostime.lua
2010-07-23 23:01 Kloot Note Added: 0005147
2010-07-23 23:01 Kloot Note Edited: 0005147
2010-07-23 23:02 Kloot Status new => closed
2010-07-23 23:02 Kloot Resolution open => no change required