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
#5
(07.06.2016, 06:17)admin Wrote: 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

Hi Admin,

Yes you are right, i add the +1 after validation, so it will never be that value

Sorry (;

BR,

Erwin
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
RE: Counter and Trend - by Erwin van der Zwart - 07.06.2016, 11:25

Forum Jump: