07.06.2016, 06:17
Erwin, that check is incorrect
256 * 256 * 256 * 256 = 0x100000000 (4294967296)
Maximum value for unsigned 32-bit integer is 0xFFFFFFFF (4294967295)
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