Does anyone know it can use "res = res - ((lua_Unsigned)1 << (size*NB));" instead of "lua_Unsigned mask = (lua_Unsigned)1 << (size*NB - 1); res = ((res ^ mask) - mask);"?
When the number is positive, ((res ^ mask) - mask) is a no-op, whereas res - (1 << (size*NB)) is not.