supplierdeeply

os.time overflow

  • 2 Replies
  • 113 Views
os.time overflow
« on: 30 / January / 2019, 03:13:12 »
Advertisements
Can the following script come to an overflow so that the loop hangs forever?


Code: [Select]
z        = 0
shots    = 99999
interval = 3000
t1=os.time()
repeat
  if os.difftime(os.time(),t1)>=0 then
    t1=os.time()+interval
    z=z+1
    shoot()
  end
until z==shots

*

Offline reyalp

  • ******
  • 11706
Re: os.time overflow
« Reply #1 on: 30 / January / 2019, 17:01:00 »
Can the following script come to an overflow so that the loop hangs forever?

I don't think it should, within reason*. According to the documentation I wrote when I implemented the os lib:
Quote
os.difftime: Just returns (unsigned int)t1 - (unsigned int)t2
So, the result shouldn't be negative unless the *difference* exceeds 2^31 seconds.

* os.time is seconds since 1970 similar to a unix timestamp, so camera time calculations including CHDK Lua will be affected by the Y2038 bug.
« Last Edit: 31 / January / 2019, 17:04:51 by reyalp »
Don't forget what the H stands for.

Re: os.time overflow
« Reply #2 on: 31 / January / 2019, 04:35:49 »
* os.time is seconds since 1970 similar to a unix timestamp, so camera time calculations including CHDK Lua will be affected by the Y2038 bug.
Thanks, then I have some time left ...  :)

 

Related Topics