```\nfunction updateTemperature(int8 bT, uint256 caseId) private {\n        uint256 t = s.w.t;\n        if (bT < 0) {\n            if (t <= uint256(-bT)) {\n                // if (change < 0 && t <= uint32(-change)),\n                // then 0 <= t <= type(int8).max because change is an int8.\n                // Thus, downcasting t to an int8 will not cause overflow.\n                bT = 1 - int8(t);\n                s.w.t = 1;\n            } else {\n                s.w.t = uint32(t - uint256(-bT));\n            }\n        } else {\n            s.w.t = uint32(t + uint256(bT));\n        }\n\n        emit TemperatureChange(s.season.current, caseId, bT);\n    }\n```\n