This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Counter and Trend
#4
Erwin, that check is incorrect
256 * 256 * 256 * 256 = 0x100000000 (4294967296)
Maximum value for unsigned 32-bit integer is 0xFFFFFFFF (4294967295)

Code:
if event.getvalue() then
  value = grp.getvalue('1/1/1') + 1
  
  -- overflow check
  if value > 0xFFFFFFFF then
    value = 0
  end

  grp.update('1/1/1', value)
end
Reply


Messages In This Thread
Counter and Trend - by managementboy - 06.06.2016, 12:29
RE: Counter and Trend - by admin - 06.06.2016, 13:19
RE: Counter and Trend - by admin - 07.06.2016, 06:17

Forum Jump: