The first law of thermodynamics can be written as
![\Delta U = Q-W](https://tex.z-dn.net/?f=%5CDelta%20U%20%3D%20Q-W)
where
![\Delta U](https://tex.z-dn.net/?f=%5CDelta%20U)
is the variation of internal energy of the system
![Q](https://tex.z-dn.net/?f=Q)
is the amount of heat absorbed by the system
![W](https://tex.z-dn.net/?f=W)
is the work done by the system on the surrounding.
Using this form, the sign convention for Q and W becomes:
Q > 0 --> heat absorbed by the system (because it increases the internal energy)
Q < 0 --> heat released by the system (because it decreases the internal energy)
W > 0 --> work done by the system (for instance, an expansion: when the system expands, it does work on the surrounding, and so the internal energy decreases, this is why there is a negative sign in the formula Q-W)
W < 0 --> work done by the surrounding on the system (for instance, a compression: when the system is compressed, the surrounding is doing work on the system, and so the internal energy of the system increases)